common

package
v0.0.0-...-83e7a96 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CERT_NULL = iota
	CERT_HASHCASH
	CERT_HIDDEN
	CERT_SIGNED
	CERT_MULTIPLE
	CERT_KEY
)

Certificate Types

View Source
const (
	KEYCERT_SIGN_DSA_SHA1 = iota
	KEYCERT_SIGN_P256
	KEYCERT_SIGN_P384
	KEYCERT_SIGN_P521
	KEYCERT_SIGN_RSA2048
	KEYCERT_SIGN_RSA3072
	KEYCERT_SIGN_RSA4096
	KEYCERT_SIGN_ED25519
	KEYCERT_SIGN_ED25519PH
)

Key Certificate Signing Key Types

View Source
const (
	KEYCERT_SIGN_DSA_SHA1_SIZE  = 128
	KEYCERT_SIGN_P256_SIZE      = 64
	KEYCERT_SIGN_P384_SIZE      = 96
	KEYCERT_SIGN_P521_SIZE      = 132
	KEYCERT_SIGN_RSA2048_SIZE   = 256
	KEYCERT_SIGN_RSA3072_SIZE   = 384
	KEYCERT_SIGN_RSA4096_SIZE   = 512
	KEYCERT_SIGN_ED25519_SIZE   = 32
	KEYCERT_SIGN_ED25519PH_SIZE = 32
)

SigningPublicKey sizes for Signing Key Types

View Source
const (
	KEYCERT_PUBKEY_SIZE = 256
	KEYCERT_SPK_SIZE    = 128
)

Sizes of structures in KeyCertificates

View Source
const (
	KEYS_AND_CERT_PUBKEY_SIZE = 256
	KEYS_AND_CERT_SPK_SIZE    = 128
	KEYS_AND_CERT_MIN_SIZE    = 387
	KEYS_AND_CERT_DATA_SIZE   = 384
)

Sizes of various KeysAndCert structures and requirements

View Source
const (
	LEASE_SIZE           = 44
	LEASE_HASH_SIZE      = 32
	LEASE_TUNNEL_ID_SIZE = 4
)

Sizes or various components of a Lease

View Source
const (
	LEASE_SET_PUBKEY_SIZE = 256
	LEASE_SET_SPK_SIZE    = 128
	LEASE_SET_SIG_SIZE    = 40
)

Sizes of various structures in an I2P LeaseSet

View Source
const (
	CERT_MIN_SIZE = 3
)

Minimum size of a valid Certificate

View Source
const (
	INTEGER_SIZE = 8
)

Total byte length of an I2P integer

View Source
const (
	KEYCERT_CRYPTO_ELG = iota
)

Key Certificate Public Key Types

View Source
const (
	KEYCERT_CRYPTO_ELG_SIZE = 256
)

PublicKey sizes for Public Key Types

View Source
const (
	ROUTER_ADDRESS_MIN_SIZE = 9
)

Minimum number of bytes in a valid RouterAddress

View Source
const (
	STRING_MAX_SIZE = 255
)

Maximum number of bytes that can be stored in an I2P string

Variables

This section is empty.

Functions

func Integer

func Integer(number []byte) (value int)

Interpret a slice of bytes from length 0 to length 8 as a big-endian integer and return an int representation.

Types

type Certificate

type Certificate []byte

func ReadCertificate

func ReadCertificate(data []byte) (certificate Certificate, remainder []byte, err error)

Read a Certificate from a slice of bytes, returning any extra data on the end of the slice and any errors if a valid Certificate could not be read.

func (Certificate) Data

func (certificate Certificate) Data() (data []byte, err error)

Return the Certificate data and any errors encountered parsing the Certificate.

func (Certificate) Length

func (certificate Certificate) Length() (length int, err error)

Look up the length of the Certificate, reporting errors if the certificate is shorter than the minimum certificate size or if the reported length doesn't match the provided data.

func (Certificate) Type

func (certificate Certificate) Type() (cert_type int, err error)

Return the Certificate Type specified in the first byte of the Certificate, and an error if the certificate is shorter than the minimum certificate size.

type Date

type Date [8]byte

func (Date) Time

func (date Date) Time() (date_time time.Time)

Time takes the value stored in date as an 8 byte big-endian integer representing the number of milliseconds since the beginning of unix time and converts it to a Go time.Time struct.

type Destination

type Destination []byte

A Destination is a KeysAndCert with functionallity for generating base32 and base64 addresses.

func ReadDestination

func ReadDestination(data []byte) (destination Destination, remainder []byte, err error)

func (Destination) Base32Address

func (destination Destination) Base32Address() (str string)

Generate the I2P base32 address for this Destination.

func (Destination) Base64

func (destination Destination) Base64() string

Generate the I2P base64 address for this Destination.

func (Destination) Certificate

func (destination Destination) Certificate() (Certificate, error)

func (Destination) PublicKey

func (destination Destination) PublicKey() (crypto.PublicKey, error)

func (Destination) SigningPublicKey

func (destination Destination) SigningPublicKey() (crypto.SigningPublicKey, error)

type Hash

type Hash [32]byte

sha256 hash of some data

func HashData

func HashData(data []byte) (h Hash)

calculate sha256 of a byte slice

func HashReader

func HashReader(r io.Reader) (h Hash, err error)

calulate sha256 of all data being read from an io.Reader return error if one occurs while reading from reader

type KeyCertificate

type KeyCertificate []byte

func (KeyCertificate) ConstructPublicKey

func (key_certificate KeyCertificate) ConstructPublicKey(data []byte) (public_key crypto.PublicKey, err error)

Given some bytes, build a PublicKey using any excess data that may be stored in the KeyCertificate and return it along with any errors encountered constructing the PublicKey.

func (KeyCertificate) ConstructSigningPublicKey

func (key_certificate KeyCertificate) ConstructSigningPublicKey(data []byte) (signing_public_key crypto.SigningPublicKey, err error)

Given some bytes, build a SigningPublicKey using any excess data that may be stored in the KeyCertificate and return it along with any errors encountered constructing the SigningPublicKey.

func (KeyCertificate) Data

func (key_certificate KeyCertificate) Data() ([]byte, error)

The data contained in the Key Certificate.

func (KeyCertificate) PublicKeyType

func (key_certificate KeyCertificate) PublicKeyType() (pubkey_type int, err error)

The PublicKey type this Key Certificate describes and any errors encountered parsing this KeyCertificate.

func (KeyCertificate) SignatureSize

func (key_certificate KeyCertificate) SignatureSize() (size int)

Return the size of a Signature corresponding to the Key Certificate's SigningPublicKey type.

func (KeyCertificate) SigningPublicKeyType

func (key_certificate KeyCertificate) SigningPublicKeyType() (signing_pubkey_type int, err error)

The SigningPublicKey type this Key Certificate describes and any errors encountered parsing the KeyCertificate.

type KeysAndCert

type KeysAndCert []byte

func ReadKeysAndCert

func ReadKeysAndCert(data []byte) (keys_and_cert KeysAndCert, remainder []byte, err error)

Read a KeysAndCert from a slice of bytes, retuning it and the remaining data as well as any errors encoutered parsing the KeysAndCert.

func (KeysAndCert) Certificate

func (keys_and_cert KeysAndCert) Certificate() (cert Certificate, err error)

Return the Certificate contained in the KeysAndCert and any errors encountered while parsing the KeysAndCert or Certificate.

func (KeysAndCert) PublicKey

func (keys_and_cert KeysAndCert) PublicKey() (key crypto.PublicKey, err error)

Return the PublicKey for this KeysAndCert, reading from the Key Certificate if it is present to determine correct lengths.

func (KeysAndCert) SigningPublicKey

func (keys_and_cert KeysAndCert) SigningPublicKey() (signing_public_key crypto.SigningPublicKey, err error)

Return the SigningPublicKey for this KeysAndCert, reading from the Key Certificate if it is present to determine correct lengths.

type Lease

type Lease [LEASE_SIZE]byte

func (Lease) Date

func (lease Lease) Date() (date Date)

Return the Date inside the Lease.

func (Lease) TunnelGateway

func (lease Lease) TunnelGateway() (hash Hash)

Return the first 32 bytes of the Lease as a Hash.

func (Lease) TunnelID

func (lease Lease) TunnelID() uint32

Parse the TunnelID Integer in the Lease.

type LeaseSet

type LeaseSet []byte

func (LeaseSet) Destination

func (lease_set LeaseSet) Destination() (destination Destination, err error)

Read a Destination from the LeaseSet.

func (LeaseSet) LeaseCount

func (lease_set LeaseSet) LeaseCount() (count int, err error)

Return the number of Leases specified by the LeaseCount value in this LeaseSet.

func (LeaseSet) Leases

func (lease_set LeaseSet) Leases() (leases []Lease, err error)

Read the Leases in this LeaseSet, returning a partial set if there is insufficient data.

func (LeaseSet) NewestExpiration

func (lease_set LeaseSet) NewestExpiration() (oldest Date, err error)

Return the oldest date from all the Leases in the LeaseSet.

func (LeaseSet) OldestExpiration

func (lease_set LeaseSet) OldestExpiration() (earliest Date, err error)

Return the oldest date from all the Leases in the LeaseSet.

func (LeaseSet) PublicKey

func (lease_set LeaseSet) PublicKey() (public_key crypto.ElgPublicKey, err error)

Return the PublicKey in this LeaseSet and any errors ancountered parsing the LeaseSet.

func (LeaseSet) Signature

func (lease_set LeaseSet) Signature() (signature Signature, err error)

Return the Signature data for the LeaseSet, as specified in the Destination's Key Certificate if present or the 40 bytes following the Leases.

func (LeaseSet) SigningKey

func (lease_set LeaseSet) SigningKey() (signing_public_key crypto.SigningPublicKey, err error)

Return the SigningPublicKey, as specified in the LeaseSet's Destination's Key Certificate if present, or a legacy DSA key.

func (LeaseSet) Verify

func (lease_set LeaseSet) Verify() error

type Mapping

type Mapping []byte

func GoMapToMapping

func GoMapToMapping(gomap map[string]string) (mapping Mapping, err error)

Convert a Go map of unformatted strings to a sorted Mapping.

func ValuesToMapping

func ValuesToMapping(values MappingValues) (mapping Mapping)

Convert a MappingValue struct to a Mapping. The values are first sorted in the order defined in mappingOrder.

func (Mapping) HasDuplicateKeys

func (mapping Mapping) HasDuplicateKeys() bool

Return true if two keys in a mapping are identical.

func (Mapping) Values

func (mapping Mapping) Values() (map_values MappingValues, errs []error)

Returns the values contained in a Mapping in the form of a MappingValues.

type MappingValues

type MappingValues [][2]String

Parsed key-values pairs inside a Mapping.

type RouterAddress

type RouterAddress []byte

func ReadRouterAddress

func ReadRouterAddress(data []byte) (router_address RouterAddress, remainder []byte, err error)

Given a slice of bytes, read a RouterAddress, returning the remaining bytes and any errors encountered parsing the RouterAddress.

func (RouterAddress) Cost

func (router_address RouterAddress) Cost() (cost int, err error)

Return the cost integer for this RouterAddress and any errors encountered parsing the RouterAddress.

func (RouterAddress) Expiration

func (router_address RouterAddress) Expiration() (date Date, err error)

Return the Date this RouterAddress expires and any errors encountered parsing the RouterAddress.

func (RouterAddress) Options

func (router_address RouterAddress) Options() (mapping Mapping, err error)

Return the Mapping containing the options for this RouterAddress and any errors encountered parsing the RouterAddress.

func (RouterAddress) TransportStyle

func (router_address RouterAddress) TransportStyle() (str String, err error)

Return the Transport type for this RouterAddress and any errors encountered parsing the RouterAddress.

type RouterIdentity

type RouterIdentity []byte

A RouterIdentity is identical to KeysAndCert.

func ReadRouterIdentity

func ReadRouterIdentity(data []byte) (router_identity RouterIdentity, remainder []byte, err error)

func (RouterIdentity) Certificate

func (router_identity RouterIdentity) Certificate() (Certificate, error)

func (RouterIdentity) PublicKey

func (router_identity RouterIdentity) PublicKey() (crypto.PublicKey, error)

func (RouterIdentity) SigningPublicKey

func (router_identity RouterIdentity) SigningPublicKey() (crypto.SigningPublicKey, error)

type RouterInfo

type RouterInfo []byte

func (RouterInfo) IdentHash

func (router_info RouterInfo) IdentHash() (h Hash, err error)

Calculate this RouterInfo's Identity Hash (the sha256 of the RouterIdentity) returns error if the RouterIdentity is malformed

func (RouterInfo) Options

func (router_info RouterInfo) Options() (mapping Mapping)

Return the Options Mapping inside this RouterInfo.

func (RouterInfo) PeerSize

func (router_info RouterInfo) PeerSize() int

Return the PeerSize value, currently unused and always zero.

func (RouterInfo) Published

func (router_info RouterInfo) Published() (date Date, err error)

Return the Date the RouterInfo was published and any errors encountered parsing the RouterInfo.

func (RouterInfo) RouterAddressCount

func (router_info RouterInfo) RouterAddressCount() (count int, err error)

Return the Integer representing the number of RouterAddresses that are contained in this RouterInfo.

func (RouterInfo) RouterAddresses

func (router_info RouterInfo) RouterAddresses() (router_addresses []RouterAddress, err error)

Read the RouterAddresses inside this RouterInfo and return them in a slice, returning a partial list if data is missing.

func (RouterInfo) RouterIdentity

func (router_info RouterInfo) RouterIdentity() (router_identity RouterIdentity, err error)

Read a RouterIdentity from the RouterInfo, returning the RouterIdentity and any errors encountered parsing the RouterIdentity.

func (RouterInfo) Signature

func (router_info RouterInfo) Signature() (signature Signature)

Return the signature of this router info

type SessionKey

type SessionKey [32]byte

type SessionTag

type SessionTag [32]byte

type Signature

type Signature []byte

type String

type String []byte

func ReadString

func ReadString(data []byte) (str String, remainder []byte, err error)

Read a string from a slice of bytes, returning any extra data on the end of the slice and any errors encountered parsing the String.

func ToI2PString

func ToI2PString(data string) (str String, err error)

This function takes an unformatted Go string and returns a String and any errors encountered during the encoding.

func (String) Data

func (str String) Data() (data string, err error)

Return the string data and any errors encountered by Length.

func (String) Length

func (str String) Length() (length int, err error)

Look up the length of the string, reporting errors if the string is invalid or the specified length does not match the provided data.

Directories

Path Synopsis
base32 encoding using I2P's alphabet
base32 encoding using I2P's alphabet
base64 encoding using I2P's alphabet
base64 encoding using I2P's alphabet
fuzz

Jump to

Keyboard shortcuts

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