commonlib

package
v0.0.0-...-0f63c93 Latest Latest
Warning

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

Go to latest
Published: May 31, 2018 License: AGPL-3.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	APIVersion                  = 3
	DEBUG                       = false
	BadBlockSizeError           = errors.New("Block size is >256?  WTF?")
	ShortReadError              = errors.New("Read was truncated, but then read more data!  This should never happen!")
	NotEnoughKeyRandomnessError = errors.New("Not enough random bytes for key!  This should never happen!")
	NotEnoughIVRandomnessError  = errors.New("Not enough random bytes for IV!  This should never happen!")
	DataCorruptionError         = errors.New("Encrypted data is corrupt!")
	EncrypterWeirdEOFError      = errors.New("Encrypter: Read 0 bytes with no EOF!")
	DecrypterWeirdEOFError      = errors.New("Decrypter: Read 0 bytes with no EOF!")

	// We use a custom base-64 encoding because:
	//
	//   * '/' and '=' tend to introduce line breaks or breaks in text selection
	//   * '/' is the path separator in S3
	Encoding = base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxzy0123456789+_").WithPadding(base64.NoPadding)
)
View Source
var GitCommit string
View Source
var SourceUrlPrefix = "https://github.com/waucka/secretshare"
View Source
var Version string

Functions

func DEBUGPrintf

func DEBUGPrintf(format string, args ...interface{})

func DEBUGPrintln

func DEBUGPrintln(msg string)

func DecodeForHuman

func DecodeForHuman(human string) ([]byte, error)

Decodes binary data from the ASCII format

func EncodeForHuman

func EncodeForHuman(bindata []byte) string

Encodes binary data for human copy/pasting.

func GetSourceLocation

func GetSourceLocation() string

func RecvSecret

func RecvSecret(bucket, bucketRegion string, key []byte, destDir string, newName *string, overwrite bool, progressChan chan *ProgressRecord) (*FileMetadata, *RecvError)

Types

type Decrypter

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

Decrypter implements io.Reader and allows you to read out a decrypted version of a stream.

func NewDecrypter

func NewDecrypter(stream io.Reader, messageSize int64, key []byte, progressChan chan *ProgressRecord) (*Decrypter, error)

func (*Decrypter) Read

func (self *Decrypter) Read(p []byte) (int, error)

type Encrypter

type Encrypter struct {
	TotalSize int64
	// contains filtered or unexported fields
}

Encrypter implements io.Reader and allows you to read out an encrypted version of a stream.

func NewEncrypter

func NewEncrypter(stream io.Reader, messageSize int64, key []byte, progressChan chan *ProgressRecord) (*Encrypter, error)

func (*Encrypter) Read

func (self *Encrypter) Read(p []byte) (int, error)

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

type FileMetadata

type FileMetadata struct {
	Filename string `json:"filename"`
	Filesize int64  `json:"filesize"`
}

type ProgressRecord

type ProgressRecord struct {
	Value int64
	Total int64
}

type RecvError

type RecvError struct {
	Message string
	Code    RecvErrorType
}

func (*RecvError) Error

func (self *RecvError) Error() string

type RecvErrorType

type RecvErrorType int
const (
	MetadataDownloadFailed RecvErrorType = iota
	MalformedMetadata
	RecvFileExists
	RecvCreateFailed
	DataDownloadFailed
	DecryptionFailed
)

type SendError

type SendError struct {
	Message string
	Code    SendErrorType
}

func SendSecret

func SendSecret(endpoint, bucket, bucketRegion, secretKey, filePath string, ttl int, progressChan chan *ProgressRecord) (string, string, *SendError)

func (*SendError) Error

func (self *SendError) Error() string

type SendErrorType

type SendErrorType int
const (
	MetadataUploadFailed SendErrorType = iota
	ConnectionFailed
	ServerFailed
	DataUploadFailed
	EncryptionFailed
	KeyGenFailed
	FileOpenFailed
	FileReadFailed
	UniverseFailed
)

type ServerVersionResponse

type ServerVersionResponse struct {
	ServerVersion        string `json:"server_version"`
	APIVersion           int    `json:"api_version"`
	ServerSourceLocation string `json:"server_source"`
}

type UploadRequest

type UploadRequest struct {
	TTL       int    `json:"ttl"`
	SecretKey string `json:"secret_key"`
	ObjectId  string `json:"object_id"`
}

type UploadResponse

type UploadResponse struct {
	PutURL      string      `json:"put_url"`
	Headers     http.Header `json:"headers"`
	MetaPutURL  string      `json:"meta_put_url"`
	MetaHeaders http.Header `json:"meta_headers"`
}

Jump to

Keyboard shortcuts

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