Documentation ¶
Index ¶
Constants ¶
const ( MaxBlobSize = 2097152 // 2mb, or 2 * 2^20 BlobHashSize = sha512.Size384 BlobHashHexLength = BlobHashSize * 2 // in hex, each byte is 2 chars )
Variables ¶
var ErrBlobEmpty = errors.Base("blob is empty")
var ErrBlobTooBig = errors.Base("blob must be at most " + strconv.Itoa(MaxBlobSize) + " bytes")
Functions ¶
func DecryptBlob ¶
DecryptBlob decrypts a blob
Types ¶
type Blob ¶
type Blob []byte
func (Blob) ValidForSend ¶
ValidForSend returns true if the blob size is within the limits
type BlobInfo ¶
type BlobInfo struct { Length int `json:"length"` BlobNum int `json:"blob_num"` BlobHash []byte `json:"-"` IV []byte `json:"-"` }
BlobInfo is the stream descriptor info for a single blob in a stream Encoding to and from JSON is customized to match existing behavior (see json.go in package)
func (BlobInfo) MarshalJSON ¶
func (*BlobInfo) UnmarshalJSON ¶
type BlobInfoAlias ¶
type BlobInfoAlias BlobInfo
type JSONBlobInfo ¶
type JSONBlobInfo struct { BlobInfoAlias BlobHash string `json:"blob_hash,omitempty"` IV string `json:"iv"` }
type JSONSDBlob ¶
type JSONSDBlob struct { StreamName string `json:"stream_name"` SDBlobAlias Key string `json:"key"` SuggestedFileName string `json:"suggested_file_name"` StreamHash string `json:"stream_hash"` }
type SDBlob ¶
type SDBlob struct { StreamName string `json:"-"` BlobInfos []BlobInfo `json:"blobs"` StreamType string `json:"stream_type"` Key []byte `json:"-"` SuggestedFileName string `json:"-"` StreamHash []byte `json:"-"` }
SDBlob contains information about the rest of the blobs in the stream Encoding to and from JSON is customized to match existing behavior (see json.go in package)
func (SDBlob) IsValid ¶
IsValid returns true if the set StreamHash matches the current hash of the stream data
func (SDBlob) MarshalJSON ¶
func (*SDBlob) UnmarshalJSON ¶
type SDBlobAlias ¶
type SDBlobAlias SDBlob
type Stream ¶
type Stream []Blob
func NewWithStreamName ¶ added in v2.4.10
NewWithStreamName creates a new Stream from a byte slice
func NewWithTitle ¶ added in v2.4.8
NewWithTitle creates a new Stream from a byte slice
func Reconstruct ¶
Reconstruct creates a stream from the given data using predetermined IVs and key from the SD blob NOTE: this will assume that all blobs except the last one are at max length. in theory this is not required, but in practice this is always true. if this is false, streams may not match exactly