entity

package
v0.0.0-...-5f4467c Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2017 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Overview

ThreatSpec package github.com/pki-io/core/entity as entity

Index

Constants

View Source
const EntityDefault string = `` /* 307-byte string literal not displayed */

EntityDefault provides default values for Entity.

View Source
const EntitySchema string = `` /* 1941-byte string literal not displayed */

EntitySchema defines the JSON Schema for Entity.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decrypter

type Decrypter interface {
	Id() string
	Body() EntityBody
	VerifyAuthenticationThenDecrypt(*document.Container, string) (string, error)
	VerifyThenDecrypt(*document.Container) (string, error)
}

type Encrypter

type Encrypter interface {
	Id() string
	Body() EntityBody
	EncryptThenAuthenticateString(string, string, string) (*document.Container, error)
	EncryptThenSignString(string, []Encrypter) (*document.Container, error)
}

type Entity

type Entity struct {
	document.Document
	Data EntityData
}

Entity participates in cryptographic operations, sending and receiving secured data.

func New

func New(jsonString interface{}) (*Entity, error)

New returns a new Entity.

func (*Entity) Authenticate

func (entity *Entity) Authenticate(container *document.Container, id, key string) error

Authenticate takes a Container and MACs it using the provided key.

func (*Entity) AuthenticateString

func (entity *Entity) AuthenticateString(content, id, key string) (*document.Container, error)

AuthenticateString takes a message string and key and MACs the message using the provided key.

func (*Entity) Body

func (entity *Entity) Body() EntityBody

func (*Entity) Decrypt

func (entity *Entity) Decrypt(container *document.Container) (string, error)

Decrypt takes a Container and decrypts the content using the entities private decryption key. It returns a plaintext string.

func (*Entity) Dump

func (entity *Entity) Dump() string

Dump serializes the entity, returning a JSON string.

func (*Entity) DumpPublic

func (entity *Entity) DumpPublic() string

DumpPublic serializes the public entity data, returning a JSON string.

func (*Entity) Encrypt

func (entity *Entity) Encrypt(content string, entities []Encrypter) (*document.Container, error)

Encrypt takes a plaintext string and encrypts it for each provided entity.

func (*Entity) EncryptThenAuthenticateString

func (entity *Entity) EncryptThenAuthenticateString(content, id, key string) (*document.Container, error)

EncryptThenAuthenticateString takes a plaintext string, encrypts it using the key and the MACs the ciphertext using they key.

Note: under the hood, the key is expanded into two separate keys, one for encryption and one for signing.

func (*Entity) EncryptThenSignString

func (entity *Entity) EncryptThenSignString(content string, entities []Encrypter) (*document.Container, error)

EncryptThenSignString takes a plaintext string, encrypts it then signs the ciphertext.

func (*Entity) GenerateKeys

func (entity *Entity) GenerateKeys() error

GenerateKeys generates RSA or EC keys for the entity, depending on the KeyType set.

func (*Entity) Id

func (entity *Entity) Id() string

func (*Entity) Load

func (entity *Entity) Load(jsonString interface{}) error

Load takes a JSON string and sets the entity data.

func (*Entity) Name

func (entity *Entity) Name() string

func (*Entity) New

func (entity *Entity) New(jsonString interface{}) error

New initializes the entity.

func (*Entity) Public

func (entity *Entity) Public() (*Entity, error)

Public returns the public entity data.

func (*Entity) Sign

func (entity *Entity) Sign(container *document.Container) error

Sign takes a Container and signs it using its private signing key.

func (*Entity) SignString

func (entity *Entity) SignString(content string) (*document.Container, error)

SignString takes a message string and signs it.

func (*Entity) SymmetricDecrypt

func (entity *Entity) SymmetricDecrypt(container *document.Container, key string) (string, error)

SymmetricDecrypt takes a Container and decrypts the content using the provided key. It returns a plaintext string.

func (*Entity) SymmetricEncrypt

func (entity *Entity) SymmetricEncrypt(content, id, key string) (*document.Container, error)

SymmetricEncrypt takes a plaintext string and encrypts it with the given key.

func (*Entity) Verify

func (entity *Entity) Verify(container *document.Container) error

Verify takes a Container and verifies the signature using the entities public key.

func (*Entity) VerifyAuthentication

func (entity *Entity) VerifyAuthentication(container *document.Container, key string) error

VerifyAuthentication takes a Container and verifies the MAC for the given key.

func (*Entity) VerifyAuthenticationThenDecrypt

func (entity *Entity) VerifyAuthenticationThenDecrypt(container *document.Container, key string) (string, error)

VerifyAuthenticationThenDecrypt takes a container and verifies the MAC using the given key, then decrypts using the key, returning a plaintext string.

Note: under the hood, the key is expanded into two separate keys, one for encryption and one for signing.

func (*Entity) VerifyThenDecrypt

func (entity *Entity) VerifyThenDecrypt(container *document.Container) (string, error)

VerifyThenDecrypt takes a container, verifies the signature then decrypts, returning a plaintext string.

type EntityBody

type EntityBody struct {
	Id                   string `json:"id"`
	Name                 string `json:"name"`
	KeyType              string `json:"key-type"`
	PublicSigningKey     string `json:"public-signing-key"`
	PrivateSigningKey    string `json:"private-signing-key"`
	PublicEncryptionKey  string `json:"public-encryption-key"`
	PrivateEncryptionKey string `json:"private-encryption-key"`
}

type EntityData

type EntityData struct {
	Scope   string     `json:"scope"`
	Version int        `json:"version"`
	Type    string     `json:"type"`
	Options string     `json:"options"`
	Body    EntityBody `json:"body"`
}

EntityData represents parsed Entity JSON data.

Jump to

Keyboard shortcuts

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