cryptdata

package
v0.0.0-...-028f1de Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERR_OTHER_CODE = 1
	// Error for 'agent not support' is 110
	ERR_KEYID_NOTEXIST_CODE   = 111
	ERR_KEYID_DUPLICATED_CODE = 112
	ERR_PARAM_NOTEXIST_CODE   = 113

	// length limit of plaintext to encrypt is 190byte, see https://crypto.stackexchange.com/questions/42097/what-is-the-maximum-size-of-the-plaintext-message-for-rsa-oaep
	LIMIT_PLAINTEXT_LEN = 190
)

Variables

View Source
var (
	ErrKeyIdNotExist   = errors.New("Key id not exist")
	ErrKeyIdDuplicated = errors.New("Key id is duplicated")
	ErrParamNotExist   = errors.New("Secret param not exist")
)

Functions

func DecryptWithRsa

func DecryptWithRsa(keyId string, encrypted []byte) ([]byte, error)

func EncryptWithRsa

func EncryptWithRsa(keyId, rawData string) ([]byte, error)

func ErrToCode

func ErrToCode(err error) int

func GetSecretParam

func GetSecretParam(secretName string) (string, error)

func Init

func Init()

func RemoveRsaKey

func RemoveRsaKey(keyId string) error

Types

type KeyInfo

type KeyInfo struct {
	Id               string `json:"id"`
	CreatedTimestamp int64  `json:"createdTimestamp"`
	ExpiredTimestamp int64  `json:"expiredTimestamp"`
	PublicKey        string `json:"publicKey"`
}

func CheckKey

func CheckKey(keyId string) (*KeyInfo, error)

func GenRsaKey

func GenRsaKey(specifiedId string, timeout int) (*KeyInfo, error)

type KeyInfos

type KeyInfos []KeyInfo

func CheckKeyList

func CheckKeyList() (keyList KeyInfos)

func (KeyInfos) Len

func (k KeyInfos) Len() int

func (KeyInfos) Less

func (k KeyInfos) Less(i, j int) bool

func (KeyInfos) Swap

func (k KeyInfos) Swap(i, j int)

type ParamInfo

type ParamInfo struct {
	SecretName       string
	CreatedTimestamp int64
	ExpiredTimestamp int64
}

func CreateSecretParam

func CreateSecretParam(keyPairId, secretName string, timeout int64, encrypted []byte) (*ParamInfo, error)

Jump to

Keyboard shortcuts

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