basic

package
v1.0.11-0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2016 License: BSD-3-Clause, BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package basic is a basic implementation of a saltpack key/keyring configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Keyring

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

Keyring holds signing and box secret/public keypairs.

func NewKeyring

func NewKeyring() *Keyring

NewKeyring makes an empty new basic keyring.

func (*Keyring) GenerateBoxKey

func (k *Keyring) GenerateBoxKey() (*SecretKey, error)

GenerateBoxKey generates a new Box secret key and imports it into the keyring.

func (*Keyring) GenerateSigningKey

func (k *Keyring) GenerateSigningKey() (*SigningSecretKey, error)

GenerateSigningKey generates a signing key and import it into the keyring.

func (*Keyring) GetAllBoxSecretKeys

func (k *Keyring) GetAllBoxSecretKeys() []saltpack.BoxSecretKey

GetAllBoxSecretKeys returns all secret Box keys in the keyring.

func (*Keyring) ImportBoxEphemeralKey

func (k *Keyring) ImportBoxEphemeralKey(kid []byte) saltpack.BoxPublicKey

ImportBoxEphemeralKey takes a key ID and returns a public key useful for encryption/decryption.

func (*Keyring) ImportBoxKey

func (k *Keyring) ImportBoxKey(pub, sec *[32]byte)

ImportBoxKey imports an existing Box key into this keyring, from a raw byte arrays, first the public, and then the secret key halves.

func (*Keyring) ImportSigningKey

func (k *Keyring) ImportSigningKey(pub *[ed25519.PublicKeySize]byte, sec *[ed25519.PrivateKeySize]byte)

ImportSigningKey imports the raw signing key into the keyring.

func (*Keyring) LookupBoxPublicKey

func (k *Keyring) LookupBoxPublicKey(kid []byte) saltpack.BoxPublicKey

LookupBoxPublicKey returns the public key that corresponds to the given key ID (or "kid")

func (*Keyring) LookupBoxSecretKey

func (k *Keyring) LookupBoxSecretKey(kids [][]byte) (int, saltpack.BoxSecretKey)

LookupBoxSecretKey tries to find one of the secret keys in its keyring given the possible key IDs. It returns the index and the key, if found, and -1 and nil otherwise.

func (*Keyring) LookupSigningPublicKey

func (k *Keyring) LookupSigningPublicKey(kid []byte) saltpack.SigningPublicKey

LookupSigningPublicKey turns the given key ID ("kid") into a corresponding signing public key.

type PrecomputedSharedKey

type PrecomputedSharedKey saltpack.RawBoxKey

PrecomputedSharedKey is a basic implementation of a saltpack precomputed shared key, computed from a BasicPublicKey and a BasicPrivateKey

func (PrecomputedSharedKey) Box

func (k PrecomputedSharedKey) Box(nonce *saltpack.Nonce, msg []byte) []byte

Box runs the box computation given a precomputed key.

func (PrecomputedSharedKey) Unbox

func (k PrecomputedSharedKey) Unbox(nonce *saltpack.Nonce, msg []byte) ([]byte, error)

Unbox runs the unbox computation given a precomputed key.

type PublicKey

type PublicKey saltpack.RawBoxKey

PublicKey is a basic implementation of a saltpack public key

func (PublicKey) CreateEphemeralKey

func (k PublicKey) CreateEphemeralKey() (saltpack.BoxSecretKey, error)

CreateEphemeralKey takes a PublicKey and returns a new ephemeral secret key of the same type.

func (PublicKey) HideIdentity

func (k PublicKey) HideIdentity() bool

HideIdentity says not to hide the identity of this key.

func (PublicKey) ToKID

func (k PublicKey) ToKID() []byte

ToKID takes a Publickey and returns a "key ID" or a KID, which is just the key itself in this implementation. It can be used to identify the key.

func (PublicKey) ToRawBoxKeyPointer

func (k PublicKey) ToRawBoxKeyPointer() *saltpack.RawBoxKey

ToRawBoxKeyPointer returns a RawBoxKey from a given public key. A RawBoxKey is just a bunch of bytes that can be used in the lower-level Box libraries.

type SecretKey

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

SecretKey is a basic implementation of a saltpack private key

func NewSecretKey

func NewSecretKey(pub, sec *[32]byte) SecretKey

NewSecretKey makes a new SecretKey from the raw 32-byte arrays the represent Box public and secret keys.

func (SecretKey) Box

func (k SecretKey) Box(receiver saltpack.BoxPublicKey, nonce *saltpack.Nonce, msg []byte) []byte

Box runs the NaCl box for the given sender and receiver key.

func (SecretKey) GetPublicKey

func (k SecretKey) GetPublicKey() saltpack.BoxPublicKey

GetPublicKey returns the public key that corresponds to this secret key.

func (SecretKey) Precompute

Precompute computes a shared key with the passed public key.

func (SecretKey) Unbox

func (k SecretKey) Unbox(sender saltpack.BoxPublicKey, nonce *saltpack.Nonce, msg []byte) ([]byte, error)

Unbox runs the NaCl unbox operation on the given ciphertext and nonce, using the receiver as the secret key.

type SigningPublicKey

type SigningPublicKey saltpack.RawBoxKey

SigningPublicKey is a basic public key used for verifying signatures. It's just a wrapper around an array of bytes.

func (SigningPublicKey) ToKID

func (k SigningPublicKey) ToKID() []byte

ToKID returns the key id for this signing key. It just returns the key itself.

func (SigningPublicKey) Verify

func (k SigningPublicKey) Verify(msg []byte, sig []byte) error

Verify runs the NaCl verification routine on the given msg / sig input.

type SigningSecretKey

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

SigningSecretKey is a basic secret key used for creating signatures and also for verifying signatures. It's a wrapper around an array of bytes and also the corresponding public key.

func NewSigningSecretKey

func NewSigningSecretKey(pub *[ed25519.PublicKeySize]byte, sec *[ed25519.PrivateKeySize]byte) SigningSecretKey

NewSigningSecretKey creates a new baisic signing key fromm the input raw byte arrays.

func (SigningSecretKey) GetPublicKey

func (k SigningSecretKey) GetPublicKey() saltpack.SigningPublicKey

GetPublicKey gets the public key that corresponds to this secret signing key

func (SigningSecretKey) Sign

func (k SigningSecretKey) Sign(msg []byte) (ret []byte, err error)

Sign runs the NaCl signature scheme on the input message, returning a signature.

Jump to

Keyboard shortcuts

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