generalcryptosystem

package module
v0.0.0-...-9290e7f Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2017 License: MIT Imports: 15 Imported by: 0

README

generalcryptosystem

General Comprehensive Cryptosystem

Documentation

Overview

A Public key cryptosystem based on eighter discrete logarithms or elliptic curves. This Package implements a fully integrated Public Key System. Every Keypair can be used for both, signatures and encryption. The Encryption is done using a simple Diffie-Hellman-Scheme with symetric cipher. The signature scheme is based on Schnorr's signature (see https://en.wikipedia.org/wiki/Schnorr_signature ).

For Encryption, the cipher Twofish ist used in 256-bit mode. For Hashing (Schnorr signature) BLAKE2b is used, where BLAKE2b is used as keyed MAC.

Index

Constants

View Source
const (
	EInvalidGroup = ErrorCode(iota)
	EHeaderTooBig
	EGroupMismatch
)
View Source
const (
	/* ModP groups (see RFC-3526) */
	Modp5  = Group(iota) /* 1536-bit MODP Group */
	Modp14               /* 2048-bit MODP Group */
	Modp15               /* 3072-bit MODP Group */
	Modp16               /* 4096-bit MODP Group */
	Modp17               /* 6144-bit MODP Group */
	Modp18               /* 8192-bit MODP Group */

	/* Curves ... */
	FIPS_P224 /* P-224 (see FIPS 186-3, section D.2.2) */
	FIPS_P256 /* P-256 (see FIPS 186-3, section D.2.3) */
	FIPS_P384 /* P-384 (see FIPS 186-3, section D.2.4) */
	FIPS_P521 /* P-521 (see FIPS 186-3, section D.2.5) */

	Koblitz_S160 /* secp160k1 (see SEC 2 section 2.4.1) */
	Koblitz_S192 /* secp192k1 (see SEC 2 section 2.5.1) */
	Koblitz_S224 /* secp224k1 (see SEC 2 section 2.6.1) */
	Koblitz_S256 /* secp256k1 (see SEC 2 section 2.7.1) */

	/* Brainpool Curves. (Non-NSA curves) */
	Brainpool_P160r1
	Brainpool_P160t1
	Brainpool_P192r1
	Brainpool_P192t1
	Brainpool_P224r1
	Brainpool_P224t1
	Brainpool_P256r1
	Brainpool_P256t1
	Brainpool_P320r1
	Brainpool_P320t1
	Brainpool_P384r1
	Brainpool_P384t1
	Brainpool_P512r1
	Brainpool_P512t1

	/* Complex number groups, see github.com/maxymania/complexdh */
	Complex_2048bit
	Complex_4096bit
	Complex_8192bit
)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(priv *PrivateKey, src io.Reader) (io.Reader, error)

func Encrypt

func Encrypt(pub *PublicKey, r io.Reader, dest io.Writer) (io.WriteCloser, error)

func GenerateKeyPair

func GenerateKeyPair(group ObjectID, r io.Reader) (*PublicKey, *PrivateKey, error)

Types

type ErrorCode

type ErrorCode uint

func (ErrorCode) Error

func (e ErrorCode) Error() string

type Group

type Group uint

func (Group) ID

func (g Group) ID() ObjectID

func (Group) Valid

func (g Group) Valid() bool

type ObjectID

type ObjectID []int

type PrivateKey

type PrivateKey struct {
	Group  ObjectID
	Secret *big.Int
}

func (*PrivateKey) PublicKey

func (priv *PrivateKey) PublicKey() *PublicKey

Generates the Public Key from the Private Key. This is useful, if the user lost his Public Key. If the operation is not supported, the method shall return nil.

type PublicKey

type PublicKey struct {
	Group ObjectID
	X, Y  *big.Int
	Z     []byte
}

type Signature

type Signature struct {
	Sig  *big.Int
	Hash []byte
}

type Signer

type Signer interface {
	io.Writer

	Sign() *Signature
}

func Sign

func Sign(priv *PrivateKey, r io.Reader) (Signer, error)

type Verifier

type Verifier interface {
	io.Writer

	Verify() bool
}

func Verify

func Verify(pub *PublicKey, sig *Signature) (Verifier, error)

Jump to

Keyboard shortcuts

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