client

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 2 Imported by: 0

README

Heimdall client (Go)

Package
go get github.com/PumpkinSeed/heimdall
Usage

Encrypt/Decrypt example

package anything

import (
	"context"

	"github.com/PumpkinSeed/heimdall/pkg/client"
	"github.com/PumpkinSeed/heimdall/pkg/client/grpc"
	"github.com/PumpkinSeed/heimdall/pkg/structs"
)

func main() {
	hclient := client.New(grpc.Options{
		// Add more endpoints so the client can load-balance with round-robin algorithm
		URLs: []string{"10.0.0.1:9090", "10.0.0.2:9090"},
		TLS:  false,
	})
	
	var key = "test"
	hclient.CreateKey(context.Background(), &structs.Key{Name: key})
	// output: error
	hclient.ReadKey(context.Background(), key)
	// output: Key struct, error

	var plaintext = "test secret"
	result, err := hclient.Encrypt(context.Background(), &structs.EncryptRequest{
		KeyName:    key,
		PlainText:  plaintext,
	})
	// output: structs.CryptoResult, error

	result, err := hclient.Decrypt(context.TODO(), &structs.DecryptRequest{
		KeyName:    key,
		Ciphertext: result.Result,
	})
	// output: structs.CryptoResult, error
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	CreateKey(ctx context.Context, key *structs.Key) (*structs.KeyResponse, error)
	ReadKey(ctx context.Context, keyName string) (*structs.KeyResponse, error)
	DeleteKey(ctx context.Context, keyName string) (*structs.KeyResponse, error)
	ListKeys(ctx context.Context) (*structs.KeyListResponse, error)
	Encrypt(ctx context.Context, encrypt *structs.EncryptRequest) (*structs.CryptoResult, error)
	Decrypt(ctx context.Context, decrypt *structs.DecryptRequest) (*structs.CryptoResult, error)
	Hash(ctx context.Context, hash *structs.HashRequest) (*structs.HashResponse, error)
	GenerateHMAC(ctx context.Context, hmac *structs.HMACRequest) (*structs.HMACResponse, error)
	Sign(ctx context.Context, in *structs.SignParameters) (*structs.SignResponse, error)
	VerifySigned(ctx context.Context, in *structs.VerificationRequest) (*structs.VerificationResponse, error)
	Rewrap(ctx context.Context, in *structs.RewrapRequest) (*structs.CryptoResult, error)
	UpdateKeyConfiguration(ctx context.Context, in *structs.KeyConfig) (*structs.Empty, error)
	RotateKey(ctx context.Context, in *structs.RotateRequest) (*structs.Empty, error)
	ExportKey(ctx context.Context, in *structs.ExportRequest) (*structs.ExportResult, error)
	BackupKey(ctx context.Context, in *structs.BackupRequest) (*structs.BackupResult, error)
	RestoreKey(ctx context.Context, in *structs.RestoreRequest) (*structs.Empty, error)
	GenerateKey(ctx context.Context, in *structs.GenerateKeyRequest) (*structs.GenerateKeyResponse, error)
	GenerateRandomBytes(ctx context.Context, in *structs.GenerateBytesRequest) (*structs.GenerateBytesResponse, error)
	Health(ctx context.Context, in *structs.HealthRequest) (*structs.HealthResponse, error)
}

func New

func New(o Options) Client

type Options

type Options interface {
	Setup() Client
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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