Documentation ¶
Index ¶
- Constants
- Variables
- func DecryptGCM(key *ManagedKey, nonce, digest, ciphertext, data []byte) ([]byte, error)
- func EncryptGCM(key *ManagedKey, nonce, plaintext, data []byte) (digest []byte, ciphertext []byte, err error)
- func PublicKeyCapabilityID(subjectKey, holderKey *ManagedKeyPair, nonce []byte) string
- func RegisterKMSType(name KMSType, instance KMSCredential)
- func SharedSecretCapabilityID(key *ManagedKey, nonce []byte) (string, error)
- type Capability
- type KMS
- type KMSCredential
- type KMSType
- type KeyPairType
- func (t KeyPairType) Generate(randomReader io.Reader) (*ManagedKeyPair, error)
- func (t KeyPairType) NonceSize() int
- func (t KeyPairType) Open(message, nonce, peersPublicKey, privateKey []byte) ([]byte, error)
- func (t KeyPairType) PrivateKeySize() int
- func (t KeyPairType) PublicKeySize() int
- func (t KeyPairType) Seal(message, nonce, peersPublicKey, privateKey []byte) ([]byte, error)
- func (t KeyPairType) String() string
- type KeyType
- func (t KeyType) BlockCipher(key []byte) (cipher.Block, error)
- func (t KeyType) BlockCrypt(iv, key, data []byte, encrypt bool) error
- func (t KeyType) BlockMode(iv, key []byte, encrypt bool) (cipher.BlockMode, error)
- func (t KeyType) BlockSize() int
- func (t KeyType) KeySize() int
- func (t KeyType) Pad(data []byte) []byte
- func (t KeyType) String() string
- func (t KeyType) Unpad(data []byte) []byte
- type ManagedKey
- type ManagedKeyPair
- type MockKMS
- type PublicKeyCapability
- type SharedSecretCapability
Constants ¶
View Source
const LocalKMSType = KMSType("local")
Variables ¶
View Source
var ( ErrInvalidPublicKey = errors.New("invalid public key") ErrInvalidPrivateKey = errors.New("invalid private key") ErrInvalidNonce = errors.New("invalid nonce") ErrMessageIntegrityFailed = errors.New("message integrity failed") )
Functions ¶
func DecryptGCM ¶
func DecryptGCM(key *ManagedKey, nonce, digest, ciphertext, data []byte) ([]byte, error)
func EncryptGCM ¶
func EncryptGCM( key *ManagedKey, nonce, plaintext, data []byte) (digest []byte, ciphertext []byte, err error)
func PublicKeyCapabilityID ¶
func PublicKeyCapabilityID(subjectKey, holderKey *ManagedKeyPair, nonce []byte) string
func RegisterKMSType ¶
func RegisterKMSType(name KMSType, instance KMSCredential)
func SharedSecretCapabilityID ¶
func SharedSecretCapabilityID(key *ManagedKey, nonce []byte) (string, error)
Types ¶
type Capability ¶
type Capability interface { // CapabilityID() returns the globally unique identifier of the // capability. It should be a string derived from a secret shared // with the recipient. CapabilityID() string // Nonce() returns the random nonce associated with the capability. // This is an optional feature (used for public-key based grants). // If there is no nonce, nil is returned. Nonce() []byte // PublicPayload returns the publicly exposed data associated // with the capability. PublicPayload() []byte // EncryptedPayload returns the encrypted payload associated with // this capability. Apply your shared secret to the value that // Challenge() returns and pass it to Verify() in order to gain // access to the plaintext of the payload. EncryptedPayload() []byte }
Capability is a generic handle on a cryptographic grant of access.
type KMS ¶
type KMS interface { GenerateNonce(bytes int) ([]byte, error) GenerateEncryptedKey(keyType KeyType, ctxKey, ctxVal string) (*ManagedKey, error) DecryptKey(*ManagedKey) error }
type KMSCredential ¶
type KMSType ¶
type KMSType string
func (KMSType) KMSCredential ¶
func (name KMSType) KMSCredential() (KMSCredential, error)
type KeyPairType ¶
type KeyPairType byte
const (
Curve25519 KeyPairType = iota
)
func (KeyPairType) Generate ¶
func (t KeyPairType) Generate(randomReader io.Reader) (*ManagedKeyPair, error)
func (KeyPairType) NonceSize ¶
func (t KeyPairType) NonceSize() int
func (KeyPairType) Open ¶
func (t KeyPairType) Open(message, nonce, peersPublicKey, privateKey []byte) ([]byte, error)
func (KeyPairType) PrivateKeySize ¶
func (t KeyPairType) PrivateKeySize() int
func (KeyPairType) PublicKeySize ¶
func (t KeyPairType) PublicKeySize() int
func (KeyPairType) Seal ¶
func (t KeyPairType) Seal(message, nonce, peersPublicKey, privateKey []byte) ([]byte, error)
func (KeyPairType) String ¶
func (t KeyPairType) String() string
type ManagedKey ¶
type ManagedKey struct { KeyType IV []byte Plaintext []byte Ciphertext []byte ContextKey string ContextValue string }
func KeyFromPasscode ¶
func KeyFromPasscode(passcode, salt []byte, keyType KeyType) *ManagedKey
func (*ManagedKey) Clone ¶
func (k *ManagedKey) Clone() ManagedKey
func (*ManagedKey) Decrypt ¶
func (k *ManagedKey) Decrypt(keyKey *ManagedKey) error
func (*ManagedKey) Encrypt ¶
func (k *ManagedKey) Encrypt(keyKey *ManagedKey) error
func (*ManagedKey) Encrypted ¶
func (k *ManagedKey) Encrypted() bool
type ManagedKeyPair ¶
type ManagedKeyPair struct { KeyPairType IV []byte PrivateKey []byte EncryptedPrivateKey []byte PublicKey []byte }
func (*ManagedKeyPair) Clone ¶
func (k *ManagedKeyPair) Clone() ManagedKeyPair
func (*ManagedKeyPair) Decrypt ¶
func (k *ManagedKeyPair) Decrypt(keyKey *ManagedKey) error
func (*ManagedKeyPair) Encrypt ¶
func (k *ManagedKeyPair) Encrypt(keyKey *ManagedKey) error
func (*ManagedKeyPair) Encrypted ¶
func (k *ManagedKeyPair) Encrypted() bool
type MockKMS ¶
type MockKMS interface { KMS KMSCredential() KMSCredential MasterKey() []byte SetMasterKey([]byte) }
type PublicKeyCapability ¶
type PublicKeyCapability struct {
Capability
}
func GrantPublicKeyCapability ¶
func GrantPublicKeyCapability( kms KMS, nonce []byte, subjectKey, holderKey *ManagedKeyPair, publicData, privateData interface{}) ( *PublicKeyCapability, error)
func (*PublicKeyCapability) DecryptPayload ¶
func (c *PublicKeyCapability) DecryptPayload(subjectKey, holderKey *ManagedKeyPair) ([]byte, error)
type SharedSecretCapability ¶
type SharedSecretCapability struct {
}func GrantSharedSecretCapability ¶
func GrantSharedSecretCapability(key *ManagedKey, nonce []byte, publicData, privateData interface{}) ( *SharedSecretCapability, error)
func (*SharedSecretCapability) DecryptPayload ¶
func (c *SharedSecretCapability) DecryptPayload(key *ManagedKey) ([]byte, error)
Click to show internal directories.
Click to hide internal directories.