crypto

package
v1.0.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 License: Apache-2.0, MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NonceLength  = 12
	SymKeyLength = 16
	TagLength    = 16
	RSAKeyLength = 3072
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CSP

type CSP interface {
	NewRSAKeys() (publicKey []byte, privateKey []byte, e error)
	NewECDSAKeys() (publicKey []byte, privateKey []byte, e error)
	VerifyMessage(publicKey []byte, message []byte, signature []byte) error
	NewSymmetricKey() ([]byte, error)
	SignMessage(privateKey []byte, message []byte) (signature []byte, e error)
	PkDecryptMessage(privateKey []byte, encryptedMessage []byte) (message []byte, e error)
	PkEncryptMessage(publicKey []byte, message []byte) ([]byte, error)
	DecryptMessage(key []byte, encryptedMessage []byte) ([]byte, error)
	EncryptMessage(key []byte, message []byte) (encryptedMessage []byte, e error)
}

CSP (Crypto Service Provider) offers a high-level abstract of cryptographic primitives used in FPC

func GetDefaultCSP

func GetDefaultCSP() CSP

type EncryptionContext

type EncryptionContext interface {
	Conceal(function string, args []string) (string, error)
	Reveal(r []byte) ([]byte, error)
}

EncryptionContext defines the interface of an object responsible to encrypt the contents of a transaction invocation and to decrypt the corresponding response. Conceal and Reveal must be called only once during the lifetime of an object that implements this interface. That is, an EncryptionContext is only valid for a single transaction invocation.

type EncryptionContextImpl

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

func (*EncryptionContextImpl) Conceal

func (e *EncryptionContextImpl) Conceal(function string, args []string) (string, error)

func (*EncryptionContextImpl) Reveal

func (e *EncryptionContextImpl) Reveal(signedResponseBytesB64 []byte) ([]byte, error)

type EncryptionProvider

type EncryptionProvider interface {
	NewEncryptionContext() (EncryptionContext, error)
}

type EncryptionProviderImpl

type EncryptionProviderImpl struct {
	CSP                CSP
	GetCcEncryptionKey func() ([]byte, error)
}

func (EncryptionProviderImpl) NewEncryptionContext

func (p EncryptionProviderImpl) NewEncryptionContext() (EncryptionContext, error)

type GoCrypto

type GoCrypto struct {
}

GoCrypto implements CSP using pure go

func NewGoCrypto

func NewGoCrypto() *GoCrypto

func (GoCrypto) DecryptMessage

func (g GoCrypto) DecryptMessage(key []byte, encryptedMessage []byte) ([]byte, error)

func (GoCrypto) EncryptMessage

func (g GoCrypto) EncryptMessage(key []byte, message []byte) (encryptedMessage []byte, err error)

func (GoCrypto) NewECDSAKeys

func (g GoCrypto) NewECDSAKeys() (publicKey []byte, privateKey []byte, err error)

func (GoCrypto) NewRSAKeys

func (g GoCrypto) NewRSAKeys() (publicKey []byte, privateKey []byte, err error)

func (GoCrypto) NewSymmetricKey

func (g GoCrypto) NewSymmetricKey() ([]byte, error)

func (GoCrypto) PkDecryptMessage

func (g GoCrypto) PkDecryptMessage(privateKey []byte, encryptedMessage []byte) (message []byte, err error)

func (GoCrypto) PkEncryptMessage

func (g GoCrypto) PkEncryptMessage(publicKey []byte, message []byte) ([]byte, error)

func (GoCrypto) SignMessage

func (g GoCrypto) SignMessage(privateKey []byte, message []byte) (signature []byte, e error)

func (GoCrypto) VerifyMessage

func (g GoCrypto) VerifyMessage(publicKey []byte, message []byte, signature []byte) error

Jump to

Keyboard shortcuts

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