utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2015 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package utils implements a few utilities for repbin commands

Index

Constants

View Source
const RepostHeaderSize = message.PadKeySize + 4 + 4

RepostHeaderSize is the length of the repost header containg repad key, min-delay and max-delay setting

View Source
const Version = "0.0.1 very alpha"

Version of this release

Variables

View Source
var (
	// ErrMaxBytes is returned if too many bytes are available
	ErrMaxBytes = errors.New("utils: Too many bytes")
	// ErrNoFiles is returned if no files could be found
	ErrNoFiles = errors.New("utils: No files found")
)
View Source
var (
	// ErrNoList is returned if list verification failed
	ErrNoList = errors.New("utils: No list")
)
View Source
var RunPeriod = int64(300) // 5min

RunPeriod is the period in which the STM delivery is started

Functions

func B58decode

func B58decode(b string) []byte

B58decode decodes a modified base58 string to a byte slice.

func B58encode

func B58encode(b []byte) string

B58encode encodes a byte slice to a modified base58 string.

func DecodeEmbedded

func DecodeEmbedded(d []byte) (k1, k2 *message.Curve25519Key)

DecodeEmbedded decodes an embedded reply public key pair

func DecodeRepostHeader

func DecodeRepostHeader(d []byte) (padkey *[message.PadKeySize]byte, minDelay uint32, maxDelay uint32)

DecodeRepostHeader decoes a repost header

func DecodeUInt64

func DecodeUInt64(i []byte) uint64

DecodeUInt64 does a safe decode of byte[] to uint64

func EncodeEmbedded

func EncodeEmbedded(k1, k2 *message.Curve25519Key) (ret []byte)

EncodeEmbedded converts two public keys into a byte slice

func EncodeRepostHeader

func EncodeRepostHeader(padkey *[message.PadKeySize]byte, minDelay uint32, maxDelay uint32) (ret [RepostHeaderSize]byte)

EncodeRepostHeader encodes the padkey, mindelay and maxdelay into a byte array

func EncodeUInt64

func EncodeUInt64(i uint64) []byte

EncodeUInt64 encodes a uint64 to byte[]

func MakeDirMany

func MakeDirMany(dir ...string) error

MakeDirMany creates many directories

func MaxRead

func MaxRead(n int64, r io.Reader) ([]byte, error)

MaxRead reads n bytes from r. If more bytes are available, return ErrMaxBytes

func MaxReadFile

func MaxReadFile(n int64, filename string) ([]byte, error)

MaxReadFile reads a file into []byte

func MaxStdinRead

func MaxStdinRead(n int64) ([]byte, error)

MaxStdinRead reads n bytes from stdin. If more bytes are available, return ErrMaxBytes

func OpenRandomFile

func OpenRandomFile(dirname string) (*os.File, error)

OpenRandomFile opens a random file from dirname

func OverWriteFile

func OverWriteFile(f string, b []byte) error

OverWriteFile overwrites an existing file

func ParseKeyPair

func ParseKeyPair(str string) (k1, k2 *message.Curve25519Key)

ParseKeyPair parses a public key pair as given on commandline

func PermString

func PermString(input []string) (permutation []string)

PermString permutates a slice of strings

func RandomUInt64

func RandomUInt64() []byte

RandomUInt64 creates a random uint64

func ReadRandomFile

func ReadRandomFile(dirname string, n int64) ([]byte, string, error)

ReadRandomFile reads a random file from dirname and deletes it

func STM

func STM(minDelay, maxDelay int) int64

STM calculates the STM time

func VerifyListContent

func VerifyListContent(d []byte) error

VerifyListContent verifies that data is in list format

func WriteNewFile

func WriteNewFile(f string, b []byte) error

WriteNewFile writes b to f IF f does not exist

func WriteStdout

func WriteStdout(b []byte) error

WriteStdout writes b to stdout

Types

This section is empty.

Directories

Path Synopsis
Package keyauth provides very simple knowledge proof for curve25519 private key belonging to shared public key
Package keyauth provides very simple knowledge proof for curve25519 private key belonging to shared public key
Package keyproof implements a simple authentication system based on ed25519 signatures Alice sends a token to Bob that authenticates Alice to Bob and contains time information Bob then verifies and counter-signs the token and sends it back to Alice Alice verifies the original token, the counter-signature and the timing information and grants access or denies it
Package keyproof implements a simple authentication system based on ed25519 signatures Alice sends a token to Bob that authenticates Alice to Bob and contains time information Bob then verifies and counter-signs the token and sends it back to Alice Alice verifies the original token, the counter-signature and the timing information and grants access or denies it
structs
Package structs implements types used in list exchange and storage on the server
Package structs implements types used in list exchange and storage on the server

Jump to

Keyboard shortcuts

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