Documentation ¶
Index ¶
- Constants
- Variables
- type Decrypter
- type Encrypter
- type Encryption
- type HybridEncryptionValue
- type Key
- type KeyPair
- type KeyProvider
- func (provider *KeyProvider) FromPrivateKey(privateKey []byte) (*KeyPair, error)
- func (provider *KeyProvider) FromPrivateKeyPath(path string) (*KeyPair, error)
- func (provider *KeyProvider) Generate() (*KeyPair, error)
- func (provider *KeyProvider) ReadPublicKey(publicKey []byte) (*PublicKey, error)
- func (provider *KeyProvider) ReadPublicKeyFromString(publicKeyString string) (*PublicKey, error)
- type PrivateKey
- type PublicKey
Constants ¶
const AesGcm = "AES_GCM"
AesGcm represents AES with the block cipher mode GCM
const AesKeyBitLength = 256
AesKeyBitLength is the used aes key length
const MaxRSAEncryptionLength = 64
MaxRSAEncryptionLength defines the max length of values which will be encrypted with RSA instead of hybrid encryption
const NonceBitLength = 96
NonceBitLength is the used nonce length
Variables ¶
var KeyProviders []string
KeyProviders contains the list of implemented key providers and is dynamically filled by the providers in keys package.
Functions ¶
This section is empty.
Types ¶
type Decrypter ¶
Decrypter decrypts a given reader stream with a given public key. This method may be exported into a library and must not be unexported.
type Encrypter ¶
Encrypter encrypts a given reader stream with a given public key. This method may be exported into a library and must not be unexported.
type Encryption ¶
type Encryption struct { Type string `json:"type"` Key string `json:"key"` Nonce string `json:"nonce"` }
Encryption contains the type, used key and the nonce (needed for AES GCM)
type HybridEncryptionValue ¶
type HybridEncryptionValue struct { Encryption Encryption `json:"encryption"` Value string `json:"value"` }
HybridEncryptionValue contains an encrypted value and information about the encryption
func NewHybridEncryptionValue ¶
func NewHybridEncryptionValue(encryptionAlgorithm string, encryptedKey string, nonce []byte, encryptedValue []byte) HybridEncryptionValue
NewHybridEncryptionValue returns a new HybridEncryptionValue object for the given parameters
type Key ¶
type Key interface { // AsString returns the key as pem formatted string AsString() (string, error) // AsBytes returns the key as pem formatted byte array AsBytes() ([]byte, error) // ToFile writes the key to disk in pem format ToFile(path string) error }
Key interface defines the common functions of a key
type KeyPair ¶
type KeyPair struct {
// contains filtered or unexported fields
}
KeyPair represents a public/private key pair
type KeyProvider ¶
KeyProvider provides functions for en- and decryption. This method may be exported into a library and must not be unexported.
func NewKeyProvider ¶
func NewKeyProvider(keyType string) (*KeyProvider, error)
NewKeyProvider creates a new KeyProvider. This method may be exported into a library and must not be unexported.
func (*KeyProvider) FromPrivateKey ¶
func (provider *KeyProvider) FromPrivateKey(privateKey []byte) (*KeyPair, error)
FromPrivateKey creates a key pair from the private key.
func (*KeyProvider) FromPrivateKeyPath ¶
func (provider *KeyProvider) FromPrivateKeyPath(path string) (*KeyPair, error)
FromPrivateKeyPath reads the keypair from the private key file path.
func (*KeyProvider) Generate ¶
func (provider *KeyProvider) Generate() (*KeyPair, error)
Generate creates a new public/private key.
func (*KeyProvider) ReadPublicKey ¶
func (provider *KeyProvider) ReadPublicKey(publicKey []byte) (*PublicKey, error)
ReadPublicKey reads a public key from an byte array.
func (*KeyProvider) ReadPublicKeyFromString ¶
func (provider *KeyProvider) ReadPublicKeyFromString(publicKeyString string) (*PublicKey, error)
ReadPublicKeyFromString reads a public key from its string representation.
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
func (*PrivateKey) AsBytes ¶
func (pk *PrivateKey) AsBytes() ([]byte, error)
AsBytes returns the key as pem formatted byte array.
func (*PrivateKey) AsString ¶
func (pk *PrivateKey) AsString() (string, error)
AsString returns the key as pem formatted string.
func (*PrivateKey) Decrypt ¶
func (pk *PrivateKey) Decrypt(input string) (string, error)
Decrypt decrypts a text which was encrypted with the Encrypt function of the Public key of the same key pair. In cases where the input is a meta value, we have to decrypt the symmetric key and use it for decrypting the real value.
func (*PrivateKey) ToFile ¶
func (pk *PrivateKey) ToFile(path string) error
ToFile writes the key to disk in pem format.
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey is the public key part of the KeyPair.