internal

package
v0.0.0-...-3edcbc6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCurve               = fmt.Errorf("ecies: invalid elliptic curve")
	ErrInvalidPublicKey           = fmt.Errorf("ecies: invalid public key")
	ErrSharedKeyIsPointAtInfinity = fmt.Errorf("ecies: shared key is point at infinity")
	ErrSharedKeyTooBig            = fmt.Errorf("ecies: shared key params are too big")
)
View Source
var (
	ErrSharedTooLong  = fmt.Errorf("ecies: shared secret is too long")
	ErrInvalidMessage = fmt.Errorf("ecies: invalid message")
)
View Source
var (
	DefaultCurve                  = ethcrypto.S256()
	ErrUnsupportedECDHAlgorithm   = fmt.Errorf("ecies: unsupported ECDH algorithm")
	ErrUnsupportedECIESParameters = fmt.Errorf("ecies: unsupported ECIES parameters")
	ErrInvalidKeyLen              = fmt.Errorf("ecies: invalid key size (> %d) in ECIESParams", maxKeyLen)
)
View Source
var (
	ECIES_AES128_SHA256 = &ECIESParams{
		Hash:      sha256.New,
		hashAlgo:  crypto.SHA256,
		Cipher:    aes.NewCipher,
		BlockSize: aes.BlockSize,
		KeyLen:    16,
	}

	ECIES_AES256_SHA256 = &ECIESParams{
		Hash:      sha256.New,
		hashAlgo:  crypto.SHA256,
		Cipher:    aes.NewCipher,
		BlockSize: aes.BlockSize,
		KeyLen:    32,
	}

	ECIES_AES256_SHA384 = &ECIESParams{
		Hash:      sha512.New384,
		hashAlgo:  crypto.SHA384,
		Cipher:    aes.NewCipher,
		BlockSize: aes.BlockSize,
		KeyLen:    32,
	}

	ECIES_AES256_SHA512 = &ECIESParams{
		Hash:      sha512.New,
		hashAlgo:  crypto.SHA512,
		Cipher:    aes.NewCipher,
		BlockSize: aes.BlockSize,
		KeyLen:    32,
	}
)
View Source
var Commit string
View Source
var NotModifiedError = errors.New("Config unchanged on server")

Functions

func AddParamsForCurve

func AddParamsForCurve(curve elliptic.Curve, params *ECIESParams)

func EciesDecrypt

func EciesDecrypt(prv PrivateKey, c, s1, s2 []byte) (m []byte, err error)

Decrypt decrypts an ECIES ciphertext.

func MaxSharedKeyLength

func MaxSharedKeyLength(pub *ecdsa.PublicKey) int

MaxSharedKeyLength returns the maximum length of the shared key the public key can produce.

Types

type App

type App struct {
	EncryptedConfig string
	SecretsDir      string
	// contains filtered or unexported fields
}

func NewApp

func NewApp(sota_config, secrets_dir string, unsafeHandlers, testing bool) (*App, error)

func (*App) CallInitFunctions

func (a *App) CallInitFunctions()

func (*App) CheckIn

func (a *App) CheckIn() error

func (*App) Extract

func (a *App) Extract() error

type ConfigFile

type ConfigFile struct {
	Value       string
	OnChanged   []string
	Unencrypted bool
}

type ConfigStruct

type ConfigStruct = map[string]*ConfigFile

func UnmarshallBuffer

func UnmarshallBuffer(c CryptoHandler, encContent []byte, decrypt bool) (ConfigStruct, error)

func UnmarshallFile

func UnmarshallFile(c CryptoHandler, encFile string, decrypt bool) (ConfigStruct, error)

type CryptoHandler

type CryptoHandler interface {
	Decrypt(value string) ([]byte, error)
	Close()
}

func NewEciesLocalHandler

func NewEciesLocalHandler(privKey crypto.PrivateKey) CryptoHandler

func NewEciesPkcs11Handler

func NewEciesPkcs11Handler(ctx *crypto11.Context, privKey crypto11.Signer) CryptoHandler

type ECIESParams

type ECIESParams struct {
	Hash func() hash.Hash // hash function

	Cipher    func([]byte) (cipher.Block, error) // symmetric cipher
	BlockSize int                                // block size of symmetric cipher
	KeyLen    int                                // length of symmetric key
	// contains filtered or unexported fields
}

func ParamsFromCurve

func ParamsFromCurve(curve elliptic.Curve) (params *ECIESParams)

ParamsFromCurve selects parameters optimal for the selected elliptic curve. Only the curves P256, P384, and P512 are supported.

type EciesCrypto

type EciesCrypto struct {
	PrivKey PrivateKey
	// contains filtered or unexported fields
}

func (*EciesCrypto) Close

func (ec *EciesCrypto) Close()

func (*EciesCrypto) Decrypt

func (ec *EciesCrypto) Decrypt(value string) ([]byte, error)

type PrivateKey

type PrivateKey interface {
	GenerateShared(pub *ecdsa.PublicKey, skLen, macLen int) (sk []byte, err error)
	Public() *ecdsa.PublicKey
}

type PrivateKeyLocal

type PrivateKeyLocal struct {
	*ecdsa.PrivateKey
}

PrivateKeyLocal is a representation of an elliptic curve private key.

func ImportECDSA

func ImportECDSA(prv *ecdsa.PrivateKey) *PrivateKeyLocal

Import an ECDSA private key as an ECIES private key.

func (*PrivateKeyLocal) GenerateShared

func (prv *PrivateKeyLocal) GenerateShared(pub *ecdsa.PublicKey, skLen, macLen int) (sk []byte, err error)

ECDH key agreement method used to establish secret keys for encryption.

func (*PrivateKeyLocal) Public

func (prv *PrivateKeyLocal) Public() *ecdsa.PublicKey

type PrivateKeyPkcs11

type PrivateKeyPkcs11 struct {
	// contains filtered or unexported fields
}

func ImportPcks11

func ImportPcks11(ctx *crypto11.Context, privKey crypto.PrivateKey) *PrivateKeyPkcs11

func (*PrivateKeyPkcs11) GenerateShared

func (prv *PrivateKeyPkcs11) GenerateShared(pub *ecdsa.PublicKey, skLen, macLen int) (sk []byte, err error)

func (*PrivateKeyPkcs11) Public

func (prv *PrivateKeyPkcs11) Public() *ecdsa.PublicKey

Jump to

Keyboard shortcuts

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