crypto

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IMailioCrypto added in v0.2.1

type IMailioCrypto interface {

	// Convert a public key in base64 format into a mailio address
	PublicKeyToMailioAddress(publicKeyBase64 string) (*string, error)

	// checks if mailio address is in expected format
	IsValidMailioAddress(address string) bool

	// create a server side handshake message (signed by server keys where public key is published to DNS)
	// serverAddress is either senders encoded email address or most common: mailio address
	ServerSideHandshake(publicServerKeyBase64 string, privateServerKeyBase64 string, domain string, senderAddress string) (*models.Handshake, error)

	// Verify any handshake message
	VerifyHandshake(handshake *models.Handshake, userPublicKeyEd25519Base64 string) (bool, error)

	// Generated ed25519 signing key pair and returns base64 public key, private key
	GenerateKeyPair() (*string, *string, error)

	// Sign message using ed25519
	Sign(message []byte, privateKeyBase64 string) ([]byte, error)

	// Verify message signature using ed25519
	Verify(message []byte, signature []byte, publicKeyBase64 string) (bool, error)

	// Encode a specific content to bytes using cbor (https://github.com/fxamacker/cbor)
	CborEncode(payload interface{}) ([]byte, error)
}

func NewMailioCrypto

func NewMailioCrypto() IMailioCrypto

type MailioCrypto

type MailioCrypto struct {
}

func (*MailioCrypto) CborDecode added in v0.2.1

func (m *MailioCrypto) CborDecode(payload []byte, output interface{}) error

Decode cbor message

func (*MailioCrypto) CborEncode

func (m *MailioCrypto) CborEncode(payload interface{}) ([]byte, error)

Encode message in Cbor format

func (*MailioCrypto) GenerateKeyPair

func (m *MailioCrypto) GenerateKeyPair() (*string, *string, error)

Generated ed25519 signing key pair and returns base64 public key, private key

func (*MailioCrypto) IsValidMailioAddress

func (m *MailioCrypto) IsValidMailioAddress(address string) bool

helper to check if the mailio address is valid

func (*MailioCrypto) PublicKeyToMailioAddress

func (m *MailioCrypto) PublicKeyToMailioAddress(publicKeyBase64 string) (*string, error)

convert public key to mailio address

func (*MailioCrypto) ServerSideHandshake added in v0.2.1

func (m *MailioCrypto) ServerSideHandshake(publicServerKeyBase64 string, privateServerKeyBase64 string, domain string, senderAddress string) (*models.Handshake, error)

Handshake from the server side (this is usually used when user has no handshake for specific sender)

func (*MailioCrypto) Sign

func (m *MailioCrypto) Sign(message []byte, privateKeyBase64 string) ([]byte, error)

Signing message using ed25519

func (*MailioCrypto) Verify

func (m *MailioCrypto) Verify(message []byte, signature []byte, publicKeyBase64 string) (bool, error)

Verify message signature using ed25519

func (*MailioCrypto) VerifyHandshake

func (m *MailioCrypto) VerifyHandshake(handshake *models.Handshake, userPublicKeyEd25519Base64 string) (bool, error)

VerifyHandshake verifies the signature of the handshake along with the basic sanity checks

Jump to

Keyboard shortcuts

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