document

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: 2

Documentation

Overview

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

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

Index

Constants

View Source
const ContainerDefault string = `` /* 271-byte string literal not displayed */

ContainerDefault sets default values for a Container.

View Source
const ContainerSchema string = `` /* 1909-byte string literal not displayed */

ContainerSchema defines the JSON schema for a Container.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	Document
	Data ContainerData
}

Container is a cryptographic document that can be signed and/or encrypted.

func NewContainer

func NewContainer(jsonData interface{}) (*Container, error)

NewContainer creates a new Container.

func (*Container) Decrypt

func (doc *Container) Decrypt(id string, privateKey string) (string, error)

Decrypt takes a private key and decrypts the Container body, return a plaintext string.

func (*Container) Dump

func (doc *Container) Dump() string

Dump serializes the Container to JSON.

func (*Container) Encrypt

func (doc *Container) Encrypt(jsonString string, keys map[string]string) error

Encrypt takes a plaintext string and group encrypts for the given public keys and updates its data to the ciphertext and inputs.

func (*Container) IsEncrypted

func (doc *Container) IsEncrypted() bool

IsEncrypted checks whether the Container is encrypted.

func (*Container) IsSigned

func (doc *Container) IsSigned() bool

IsSigned checks whether the Container is signed.

func (*Container) SymmetricDecrypt

func (doc *Container) SymmetricDecrypt(key string) (string, error)

SymmetricDecrypt takes a key and decrypts the Container body, returning a plaintext string.

func (*Container) SymmetricEncrypt

func (doc *Container) SymmetricEncrypt(jsonString, id, key string) error

SymmetricEncrypt takes a plaintext string and encrypts with the given key. It updates its data to the ciphertext and inputs.

type ContainerData

type ContainerData struct {
	Scope   string `json:"scope"`
	Version int    `json:"version"`
	Type    string `json:"type"`
	Options struct {
		Source           string            `json:"source"`
		SignatureMode    string            `json:"signature-mode"`
		SignatureInputs  map[string]string `json:"signature-inputs"`
		Signature        string            `json:"signature"`
		EncryptionKeys   map[string]string `json:"encryption-keys"`
		EncryptionMode   string            `json:"encryption-mode"`
		EncryptionInputs map[string]string `json:"encryption-inputs"`
	} `json:"options"`
	Body string `json:"body"`
}

ContainerData stores the parsed JSON data.

type Document

type Document struct {
	Schema  string
	Default string
}

Documents represents a generic JSON schema based document

func (*Document) FromJson

func (doc *Document) FromJson(data interface{}, target interface{}) (interface{}, error)

FromJson parses the provided data after verifying the schema. If the data is nil, it uses the default values set for the document.

func (*Document) ToJson

func (doc *Document) ToJson(data interface{}) (string, error)

ToJson serializes the document to JSON.

type Documenter

type Documenter interface {
	Dump()
	Load()
}

Jump to

Keyboard shortcuts

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