kms

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DecryptInput

type DecryptInput struct {
	ID        uint32            `json:"id"`
	KeyID     string            `json:"keyid" validate:"nonzero"`
	VaultID   string            `json:"vaultid" validate:"nonzero"`
	Algorithm string            `json:"algorithm,omitempty"`
	Context   map[string]string `json:"context,omitempty"`
	Payload   []byte            `json:"payload"`
}

DecryptInput contains a payload to be decrypted by DuoKey. Validation is done by calling request.New.

type DecryptOutput

type DecryptOutput struct {
	Success bool `json:"success"`
	Result  struct {
		KeyID     string `json:"keyid" validate:"nonzero"`
		Algorithm string `json:"algorithm"`
		Payload   []byte `json:"payload" validate:"nonzero"`
		ID        uint32 `json:"id"`
	} `json:"result" validate:"nonzero"`
	TargetURL           *string `json:"targetUrl"`
	Error               *string `json:"error"`
	UnauthorizedRequest bool    `json:"unAuthorizedRequest"`
	ABP                 bool    `json:"__abp"`
}

DecryptOutput contains the deserialized payload returned by the DuoKey server. Validation is done by calling request.Send.

type EncryptInput

type EncryptInput struct {
	ID        uint32            `json:"id"`
	KeyID     string            `json:"keyid" validate:"nonzero"`
	VaultID   string            `json:"vaultid" validate:"nonzero"`
	Algorithm string            `json:"algorithm,omitempty"`
	Context   map[string]string `json:"context,omitempty"`
	Payload   []byte            `json:"payload"`
}

EncryptInput contains a payload to be encrypted by DuoKey. DuoKey determines the encryption algorithm from the VaultID and KeyId. The optional field Algorithm allows you to specify a chaining mode or a padding scheme. An initial vector or a tag can be supplied using the Context field. Validation is done by calling request.New.

type EncryptOutput

type EncryptOutput struct {
	Success bool `json:"success"`
	Result  struct {
		KeyID     string `json:"keyid" validate:"nonzero"`
		Algorithm string `json:"algorithm"`
		Payload   []byte `json:"payload" validate:"nonzero"`
		ID        uint32 `json:"id"`
	} `json:"result" validate:"nonzero"`
	TargetURL           *string `json:"targetUrl"`
	Error               *string `json:"error"`
	UnauthorizedRequest bool    `json:"unAuthorizedRequest"`
	ABP                 bool    `json:"__abp"`
}

EncryptOutput contains the deserialized payload returned by the DuoKey server. Validation is done by calling request.Send.

type Endpoints

type Endpoints struct {
	BaseURL      string
	EncryptRoute string
	DecryptRoute string
	ImportRoute  string
}

Endpoints of the crypto services (all routes of the DuoKey REST API are customizable)

type ImportInput added in v0.1.1

type ImportInput struct {
	ID      uint32            `json:"id"`
	VaultID string            `json:"vaultid" validate:"nonzero"`
	Context map[string]string `json:"context,omitempty"`
	Payload []byte            `json:"payload"`
}

type ImportOutput added in v0.1.1

type ImportOutput struct {
	Success bool `json:"success"`
	Result  struct {
		KeyID string `json:"keyid" validate:"nonzero"`
		KCV   string `json:"kcv"`
		ID    uint32 `json:"id"`
	} `json:"result" validate:"nonzero"`
	TargetURL           *string `json:"targetUrl"`
	Error               *string `json:"error"`
	UnauthorizedRequest bool    `json:"unAuthorizedRequest"`
	ABP                 bool    `json:"__abp"`
}

type KMS

type KMS struct {
	*client.Client
	*Endpoints
}

KMS implements the KMSAPI interface

func NewClient added in v0.0.7

func NewClient(credentials credentials.Config, endpoints Endpoints) (*KMS, error)

New checks the credentials and returns a KMS client with the default logger.

func NewClientWithLogger added in v0.0.7

func NewClientWithLogger(credentials credentials.Config, endpoints Endpoints, logger duokey.Logger) (*KMS, error)

New checks the credentials and returns a KMS client with a custom logger.

func (*KMS) Decrypt

func (k *KMS) Decrypt(input *DecryptInput) (*DecryptOutput, error)

Decrypt API operation for DuoKey

func (*KMS) DecryptWithContext

func (k *KMS) DecryptWithContext(ctx context.Context, input *DecryptInput) (*DecryptOutput, error)

DecryptWithContext is the same operation as Decrypt. It is however possible to pass a non-nil context.

func (*KMS) Encrypt

func (k *KMS) Encrypt(input *EncryptInput) (*EncryptOutput, error)

Encrypt API operation for DuoKey

func (*KMS) EncryptWithContext

func (k *KMS) EncryptWithContext(ctx context.Context, input *EncryptInput) (*EncryptOutput, error)

EncryptWithContext is the same operation as Encrypt. It is however possible to pass a non-nil context.

func (*KMS) Import added in v0.1.1

func (k *KMS) Import(input *ImportInput) (*ImportOutput, error)

func (*KMS) ImportWithContext added in v0.1.1

func (k *KMS) ImportWithContext(ctx context.Context, input *ImportInput) (*ImportOutput, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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