keys

package
v0.0.3 Latest Latest
Warning

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

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

Documentation

Overview

The keys module containing the keys CRUD operation and relationship CRUD

model.go: definition of orm based data model

routers.go: router binding and core logic

serializers.go: definition the schema of return data

validators.go: definition the validator of form data

Index

Constants

View Source
const (
	AES_KEY_SIZE_128 = 16
	AES_KEY_SIZE_192 = 24
	AES_KEY_SIZE_256 = 32
)

Variables

This section is empty.

Functions

func DecryptData

func DecryptData(c *gin.Context)

func DeleteAESKeyModel

func DeleteAESKeyModel(condition interface{}) error

func DeleteKeyModel

func DeleteKeyModel(condition interface{}) error

func EncryptData

func EncryptData(c *gin.Context)

func KeyCreate

func KeyCreate(c *gin.Context)

func KeyDelete

func KeyDelete(c *gin.Context)

func KeyList

func KeyList(c *gin.Context)

func KeyRetrieve

func KeyRetrieve(c *gin.Context)

func KeyRotate

func KeyRotate(c *gin.Context)

func KeyUpdate

func KeyUpdate(c *gin.Context)

func KeysOperationsRegister

func KeysOperationsRegister(router *gin.RouterGroup)

func KeysRegister

func KeysRegister(router *gin.RouterGroup)

func RewrapData

func RewrapData(c *gin.Context)

func SaveOne

func SaveOne(data interface{}) error

Types

type AESKey

type AESKey string

type AESKeyModel

type AESKeyModel struct {
	gorm.Model
	KeyID   uint
	Name    int
	Version int `gorm:"uniqueIndex:keynamever;"`
	AESKey  AESKey
}

type AESPayload

type AESPayload struct {
	Plaintext string
	Pref      string
	Version   int
	Payload   string
}

type DecryptDataResponse

type DecryptDataResponse struct {
	Plaintext string `json:"plaintext"`
}

type DecryptDataSerializer

type DecryptDataSerializer struct {
	C *gin.Context
	AESPayload
}

func (*DecryptDataSerializer) Response

type DecryptDataValidator

type DecryptDataValidator struct {
	Ciphertext string `json:"ciphertext"`
	// contains filtered or unexported fields
}

func NewDecryptDataValidator

func NewDecryptDataValidator() DecryptDataValidator

func (*DecryptDataValidator) Bind

func (s *DecryptDataValidator) Bind(c *gin.Context) error

type EncryptDataResponse

type EncryptDataResponse struct {
	Ciphertext string `json:"ciphertext"`
	Version    int    `json:"version"`
}

type EncryptDataSerializer

type EncryptDataSerializer struct {
	C *gin.Context
	AESPayload
}

func (*EncryptDataSerializer) Response

type EncryptDataValidator

type EncryptDataValidator struct {
	Plaintext string `json:"plaintext"`
	// contains filtered or unexported fields
}

func NewEncryptDataValidator

func NewEncryptDataValidator() EncryptDataValidator

func NewEncryptDataValidatorFillWith

func NewEncryptDataValidatorFillWith(aesPayload AESPayload) EncryptDataValidator

func (*EncryptDataValidator) Bind

func (s *EncryptDataValidator) Bind(c *gin.Context) error

func (*EncryptDataValidator) Validate

func (s *EncryptDataValidator) Validate() error

type KeyModel

type KeyModel struct {
	gorm.Model
	KeyID                uint
	Name                 string
	Type                 KeyType
	Keys                 []AESKeyModel `gorm:"foreignKey:KeyID;constraint:OnDelete:CASCADE;"`
	AllowPlaintextBackup bool
	AutoRotatePeriod     int
	DeletionAllowed      bool
	Derived              bool
	Exportable           bool
	ImportedKey          bool
	LatestVersion        int
	MinAvailableVersion  int
	MinDecryptionVersion int
	MinEncryptionVersion int
	SupportsDecryption   bool
	SupportsDerivation   bool
	SupportsEncryption   bool
	SupportsSigning      bool
}

func FindManyKeys

func FindManyKeys() ([]KeyModel, int64, error)

func FindOneKey

func FindOneKey(condition interface{}) (KeyModel, error)

func (*KeyModel) Update

func (s *KeyModel) Update(data interface{}) error

type KeyModelValidator

type KeyModelValidator struct {
	AllowPlaintextBackup bool    `json:"allow_plaintext_backup"`
	AutoRotatePeriod     string  `json:"auto_rotate_period"`
	DeletionAllowed      string  `json:"deletion_allowed"`
	Derived              string  `json:"derived"`
	Exportable           string  `json:"exportable"`
	MinDecryptionVersion string  `json:"min_decryption_version"`
	MinEncryptionVersion string  `json:"min_encryption_version"`
	Name                 string  `json:"-"`
	Type                 KeyType `json:"type"`
	// contains filtered or unexported fields
}

func NewKeyModelValidator

func NewKeyModelValidator() KeyModelValidator

func NewKeyModelValidatorFillWith

func NewKeyModelValidatorFillWith(keyModel KeyModel) KeyModelValidator

func (*KeyModelValidator) Bind

func (s *KeyModelValidator) Bind(c *gin.Context) error

type KeyResponse

type KeyResponse struct {
	AllowPlaintextBackup bool        `json:"allow_plaintext_backup"`
	AutoRotatePeriod     int         `json:"auto_rotate_period"`
	DeletionAllowed      bool        `json:"deletion_allowed"`
	Derived              bool        `json:"derived"`
	Exportable           bool        `json:"exportable"`
	ImportedKey          bool        `json:"imported_key"`
	LatestVersion        int         `json:"latest_version"`
	MinAvailableVersion  int         `json:"min_available_version"`
	MinDecryptionVersion int         `json:"min_decryption_version"`
	MinEncryptionVersion int         `json:"min_encryption_version"`
	Name                 string      `json:"name"`
	SupportsDecryption   bool        `json:"supports_decryption"`
	SupportsDerivation   bool        `json:"supports_derivation"`
	SupportsEncryption   bool        `json:"supports_encryption"`
	SupportsSigning      bool        `json:"supports_signing"`
	Type                 KeyType     `json:"type"`
	Keys                 map[int]int `json:"keys"`
}

type KeySerializer

type KeySerializer struct {
	C *gin.Context
	KeyModel
}

func (*KeySerializer) Response

func (s *KeySerializer) Response() KeyResponse

type KeyType

type KeyType string
const (
	KEY_TYPE_AES256_GCM96 KeyType = "aes256-gcm96"
)

type KeysResponse

type KeysResponse struct {
	Keys []string `json:"keys"`
}

type KeysSerializer

type KeysSerializer struct {
	C    *gin.Context
	Keys []KeyModel
}

func (*KeysSerializer) Response

func (s *KeysSerializer) Response() KeysResponse

Jump to

Keyboard shortcuts

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