cryptopacket

package
v0.0.0-...-b5a46b0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2020 License: MIT Imports: 11 Imported by: 0

README

cryptopacket: a library to encrypt, sign, verify, and decrypt JSON data (using Tink)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptIntoJSON

func DecryptIntoJSON(dec tink.HybridDecrypt, ciphertext string, target interface{}) error

func DecryptString

func DecryptString(dec tink.HybridDecrypt, data string) (string, error)

func EncryptJSON

func EncryptJSON(enc tink.HybridEncrypt, data interface{}) (string, error)

func EncryptString

func EncryptString(enc tink.HybridEncrypt, data string) (string, error)

func Pack

func Pack(payload interface{}, keys *orckeys.Keys, registry PublicKeyRegistry, recipientOwner string) (string, error)

func PackUnencrypted

func PackUnencrypted(payload interface{}, keys *orckeys.Keys) (string, error)

func SignJSON

func SignJSON(sgn tink.Signer, data interface{}) (string, error)

func SignString

func SignString(sgn tink.Signer, data string) (string, error)

func VerifyJSON

func VerifyJSON(data interface{}, signature, publicKey string) (bool, error)

func VerifyString

func VerifyString(data, sig, publicKey string) (bool, error)

Types

type Contents

type Contents struct {
	// Timestamp is the timestamp of when the packet was wrapped.
	Timestamp string `json:"timestamp"`

	// Recipient is the canonical host of the recipient, to whom the message is encrypted.
	Recipient string `json:"recipient,omitempty"`

	// Sender is the canonical host of the sender.
	Sender string `json:"sender"`

	// Payload is the message contained in the packet.
	Payload interface{} `json:"payload"`
}

type Packet

type Packet struct {
	// Contents is the contents of the packet; the data to be signed.
	Contents Contents `json:"contents"`

	// Signature is the signature of the canonical JSON form of Contents, with the signing key associated with Contents.Sender.
	Signature string `json:"signature"`
}

func PackUnencryptedJSON

func PackUnencryptedJSON(payload interface{}, keys *orckeys.Keys) (*Packet, error)

func Unpack

func Unpack(target interface{}, ciphertext string, keys *orckeys.Keys, registry PublicKeyRegistry) (*Packet, error)

func UnpackUnencrypted

func UnpackUnencrypted(target interface{}, plaintext string, registry PublicKeyRegistry) (*Packet, error)

func UnpackWithoutVerification

func UnpackWithoutVerification(target interface{}, ciphertext string, keys *orckeys.Keys) (*Packet, error)

type PublicKeyRegistry

type PublicKeyRegistry interface {
	LookupPublicKeys(string) (*orckeys.PublicKeyPacket, error)
}

Jump to

Keyboard shortcuts

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