virgilapi

package
v4.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2017 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

type Api struct {
	Cards CardManager
	Keys  KeyManager
	// contains filtered or unexported fields
}

func New

func New(accessToken string) (*Api, error)

func NewWithConfig

func NewWithConfig(config Config) (*Api, error)

func (*Api) Decrypt

func (a *Api) Decrypt(data Buffer, key *Key) (Buffer, error)

func (*Api) DecryptString

func (a *Api) DecryptString(data string, key *Key) (Buffer, error)

Decrypt expects string, received by calling ToBase64String on Buffer, received from Encrypt or EncryptString

func (*Api) DecryptThenVerify

func (a *Api) DecryptThenVerify(data Buffer, key *Key, signerCard *Card) (Buffer, error)

func (*Api) DecryptThenVerifyString

func (a *Api) DecryptThenVerifyString(data string, key *Key, signerCard *Card) (Buffer, error)

DecryptThenVerifyString expects data to be in base64 encoding

func (*Api) Encrypt

func (a *Api) Encrypt(data Buffer, recipients ...*Card) (Buffer, error)

func (*Api) EncryptString

func (a *Api) EncryptString(data string, recipients ...*Card) (Buffer, error)

EncryptString is the same as Encrypt but expects any string

func (*Api) Sign

func (a *Api) Sign(data Buffer, key *Key) (Buffer, error)

func (*Api) SignString

func (a *Api) SignString(data string, key *Key) (Buffer, error)

func (*Api) SignThenEncrypt

func (a *Api) SignThenEncrypt(data Buffer, signerKey *Key, recipients ...*Card) (Buffer, error)

func (*Api) SignThenEncryptString

func (a *Api) SignThenEncryptString(data string, signerKey *Key, recipients ...*Card) (Buffer, error)

func (*Api) Verify

func (a *Api) Verify(data Buffer, signature Buffer, signerCard *Card) (bool, error)

func (*Api) VerifyString

func (a *Api) VerifyString(data string, signature Buffer, signerCard *Card) (bool, error)

VerifyString is the same as Verify but works with ordinary strings

type AppCredentials

type AppCredentials struct {
	AppId              string
	PrivateKey         Buffer
	PrivateKeyPassword string
}

type Buffer

type Buffer []byte

func BufferFromBase64String

func BufferFromBase64String(str string) (Buffer, error)

func BufferFromBytes

func BufferFromBytes(data []byte) Buffer

func BufferFromHEXString

func BufferFromHEXString(str string) (Buffer, error)

func BufferFromString

func BufferFromString(str string) Buffer

func (Buffer) ToBase64String

func (b Buffer) ToBase64String() string

func (Buffer) ToHEXString

func (b Buffer) ToHEXString() string

func (Buffer) ToString

func (b Buffer) ToString() string

type Card

type Card struct {
	*virgil.Card
	// contains filtered or unexported fields
}

func (*Card) Encrypt

func (c *Card) Encrypt(data Buffer) (Buffer, error)

func (*Card) EncryptString

func (c *Card) EncryptString(data string) (Buffer, error)

func (*Card) Export

func (c *Card) Export() (string, error)

func (*Card) Verify

func (c *Card) Verify(data Buffer, signature Buffer) (bool, error)

func (*Card) VerifyIdentity

func (c *Card) VerifyIdentity() (attempt *IdentityVerificationAttempt, err error)

func (*Card) VerifyString

func (c *Card) VerifyString(data string, signature Buffer) (bool, error)

type CardManager

type CardManager interface {
	Get(id string) (*Card, error)
	Create(identity string, key *Key, customFields map[string]string) (*Card, error)
	CreateGlobal(identity string, key *Key) (*Card, error)
	Import(card string) (*Card, error)
	ConfirmIdentity(actionId string, confirmationCode string) (validationToken string, err error)
	Publish(card *Card) (*Card, error)
	PublishGlobal(card *Card, validationToken string) (*Card, error)
	Revoke(card *Card, reason virgil.Enum) error
	RevokeGlobal(card *Card, reason virgil.Enum, key *Key, validationToken string) error
	Find(identities ...string) (Cards, error)
	FindGlobal(identityType string, identities ...string) (Cards, error)
}

type Cards

type Cards []*Card

func (Cards) Encrypt

func (c Cards) Encrypt(data Buffer) (Buffer, error)

func (Cards) EncryptString

func (c Cards) EncryptString(data string) (Buffer, error)

func (Cards) SignThenEncrypt

func (c Cards) SignThenEncrypt(data Buffer, signerKey *Key) (Buffer, error)

func (Cards) SignThenEncryptString

func (c Cards) SignThenEncryptString(data string, signerKey *Key) (Buffer, error)

func (Cards) ToRecipients

func (c Cards) ToRecipients() []virgilcrypto.PublicKey

type ClientParams

type ClientParams struct {
	CardServiceURL,
	ReadOnlyCardServiceURL,
	IdentityServiceURL,
	VRAServiceURL string
}

type Config

type Config struct {
	Token                string
	Credentials          *AppCredentials
	ClientParams         *ClientParams
	KeyStoragePath       string
	CardVerifiers        map[string]Buffer
	KeyType              virgilcrypto.KeyType
	SkipBuiltInVerifiers bool
}

type Context

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

type IdentityVerificationAttempt

type IdentityVerificationAttempt struct {
	TimeToLive  int
	CountToLive int
	// contains filtered or unexported fields
}

func (*IdentityVerificationAttempt) Confirm

func (a *IdentityVerificationAttempt) Confirm(confirmationCode string) (string, error)

type Key

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

func (*Key) Decrypt

func (k *Key) Decrypt(data Buffer) (Buffer, error)

func (*Key) DecryptString

func (k *Key) DecryptString(data string) (Buffer, error)

func (*Key) DecryptThenVerify

func (k *Key) DecryptThenVerify(data Buffer, card *Card) (Buffer, error)

func (*Key) DecryptThenVerifyString

func (k *Key) DecryptThenVerifyString(data string, card *Card) (Buffer, error)

func (*Key) Export

func (k *Key) Export(password string) (Buffer, error)

func (*Key) ExportPublicKey

func (k *Key) ExportPublicKey() (Buffer, error)

func (*Key) Save

func (k *Key) Save(alias string, password string) error

func (*Key) Sign

func (k *Key) Sign(data Buffer) (Buffer, error)

func (*Key) SignString

func (k *Key) SignString(data string) (Buffer, error)

func (*Key) SignThenEncrypt

func (k *Key) SignThenEncrypt(data Buffer, recipients ...*Card) (Buffer, error)

func (*Key) SignThenEncryptString

func (k *Key) SignThenEncryptString(data string, recipients ...*Card) (Buffer, error)

type KeyManager

type KeyManager interface {
	Generate() (*Key, error)
	Load(alias string, password string) (*Key, error)
}

Jump to

Keyboard shortcuts

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