Documentation
¶
Index ¶
- Variables
- func AssetFromMessage(ctx context.Context, g *globals.Context, uid gregor1.UID, ...) (res chat1.Asset, err error)
- type AssetSource
- type AttachmentInfo
- type AttachmentStash
- type BufferSource
- type Decrypter
- type Encrypter
- type ErrorWrapper
- type FileSource
- type FileStash
- type PreviewRes
- type PutS3Result
- type ReadResetter
- type SignDecrypter
- type SignEncrypter
- func (s *SignEncrypter) Encrypt(r io.Reader) (io.Reader, error)
- func (s *SignEncrypter) EncryptKey() []byte
- func (s *SignEncrypter) EncryptResume(r io.Reader, nonce signencrypt.Nonce, encKey signencrypt.SecretboxKey, ...) (io.Reader, error)
- func (s *SignEncrypter) EncryptWithNonce(r io.Reader, nonce signencrypt.Nonce) (io.Reader, error)
- func (s *SignEncrypter) EncryptedLen(size int) int
- func (s *SignEncrypter) SignKey() []byte
- func (s *SignEncrypter) VerifyKey() []byte
- type StashKey
- type Store
- func (a *Store) DecryptAsset(ctx context.Context, w io.Writer, body io.Reader, asset chat1.Asset, ...) error
- func (a *Store) DeleteAsset(ctx context.Context, params chat1.S3Params, signer s3.Signer, ...) error
- func (a *Store) DeleteAssets(ctx context.Context, params chat1.S3Params, signer s3.Signer, ...) error
- func (a *Store) DownloadAsset(ctx context.Context, params chat1.S3Params, asset chat1.Asset, w io.Writer, ...) error
- func (a *Store) GetAssetReader(ctx context.Context, params chat1.S3Params, asset chat1.Asset, ...) (io.ReadCloser, error)
- func (a *Store) PutS3(ctx context.Context, r io.Reader, size int64, task *UploadTask, ...) (*PutS3Result, error)
- func (a *Store) UploadAsset(ctx context.Context, task *UploadTask) (chat1.Asset, error)
- type StreamSource
- type UploadTask
Constants ¶
This section is empty.
Variables ¶
var ErrAbortOnPartMismatch = errors.New("local part mismatch, aborting upload")
ErrAbortOnPartMismatch is returned when there is a mismatch between a current part and a previous attempt part. If ErrAbortOnPartMismatch is returned, the caller should abort the upload attempt and start from scratch.
var ErrPartNotFound = errors.New("part does not exist in stash")
Functions ¶
Types ¶
type AssetSource ¶
type AssetSource interface {
FileSize() int
Basename() string
Open(sessionID int, cli *keybase1.StreamUiClient) (ReadResetter, error)
Close() error
}
type AttachmentInfo ¶
type AttachmentInfo struct {
ObjectKey string // s3 destination
EncKey signencrypt.SecretboxKey // encryption key
SignKey signencrypt.SignKey // signing key
VerifyKey signencrypt.VerifyKey // verification key
Parts map[int]string // map of parts uploaded to S3, key == part number, value == hash of ciphertext
StartedAt time.Time // when the upload started
}
type AttachmentStash ¶
type BufferSource ¶
type BufferSource struct {
// contains filtered or unexported fields
}
func (*BufferSource) Basename ¶
func (b *BufferSource) Basename() string
func (*BufferSource) Bytes ¶
func (b *BufferSource) Bytes() []byte
func (*BufferSource) Close ¶
func (b *BufferSource) Close() error
func (*BufferSource) FileSize ¶
func (b *BufferSource) FileSize() int
func (*BufferSource) Open ¶
func (b *BufferSource) Open(sessionID int, cli *keybase1.StreamUiClient) (ReadResetter, error)
type Decrypter ¶
type Decrypter interface {
// Decrypt takes a ciphertext reader, encryption and verify keys.
// It returns a plaintext reader. It uses the constant nonce.
Decrypt(ciphertext io.Reader, encKey, verifyKey []byte) (plaintext io.Reader)
// DecryptWithNonce takes a ciphertext reader, nonce, encryption and verify keys.
// It returns a plaintext reader.
DecryptWithNonce(ciphertext io.Reader, nonce signencrypt.Nonce, encKey, verifyKey []byte) (plaintext io.Reader)
}
type Encrypter ¶
type Encrypter interface {
// EncryptedLen returns the number of bytes that the ciphertext of
// size plaintext bytes will be.
EncryptedLen(size int) int
// Encrypt takes a plaintext reader and returns a ciphertext reader.
// It generates new keys every time it is called and uses a
// constant nonce.
Encrypt(plaintext io.Reader) (ciphertext io.Reader, err error)
// EncryptWithNonce takes a plaintext reader and returns a ciphertext reader.
// It generates new keys every time it is called and uses
// the provided nonce.
EncryptWithNonce(plaintext io.Reader, nonce signencrypt.Nonce) (ciphertext io.Reader, err error)
// EncryptResume takes a plaintext reader and a set of keys. It
// returns a ciphertext reader. It *does not* generate new keys
// but uses the parameter keys. These keys should *only* be used
// to encrypt the same plaintext as a previous attempt.
EncryptResume(r io.Reader, nonce signencrypt.Nonce, encKey signencrypt.SecretboxKey, signKey signencrypt.SignKey, verifyKey signencrypt.VerifyKey) (io.Reader, error)
// EncryptKey returns the ephemeral key that was used during the
// last invocation of Encrypt.
EncryptKey() []byte
// VerifyKey returns the public portion of the signing key used during
// the last invocation of Encrypt. It can be used for signature
// verification.
VerifyKey() []byte
}
type ErrorWrapper ¶
type ErrorWrapper struct {
// contains filtered or unexported fields
}
func NewErrorWrapper ¶
func NewErrorWrapper(prefix string, err error) *ErrorWrapper
func (*ErrorWrapper) Details ¶
func (e *ErrorWrapper) Details() string
func (*ErrorWrapper) Error ¶
func (e *ErrorWrapper) Error() string
type FileSource ¶
type FileSource struct {
chat1.LocalFileSource
// contains filtered or unexported fields
}
func NewFileSource ¶
func NewFileSource(s chat1.LocalFileSource) (*FileSource, error)
func (*FileSource) Basename ¶
func (f *FileSource) Basename() string
func (*FileSource) Close ¶
func (f *FileSource) Close() error
func (*FileSource) FileSize ¶
func (f *FileSource) FileSize() int
func (*FileSource) Open ¶
func (f *FileSource) Open(sessionID int, cli *keybase1.StreamUiClient) (ReadResetter, error)
type PreviewRes ¶
type PutS3Result ¶
PutS3Result is the success result of calling PutS3.
type ReadResetter ¶
type SignDecrypter ¶
type SignDecrypter struct{}
func NewSignDecrypter ¶
func NewSignDecrypter() *SignDecrypter
func (*SignDecrypter) DecryptWithNonce ¶
func (s *SignDecrypter) DecryptWithNonce(r io.Reader, nonce signencrypt.Nonce, encKey, verifyKey []byte) (plaintext io.Reader)
type SignEncrypter ¶
type SignEncrypter struct {
// contains filtered or unexported fields
}
func NewSignEncrypter ¶
func NewSignEncrypter() *SignEncrypter
func (*SignEncrypter) EncryptKey ¶
func (s *SignEncrypter) EncryptKey() []byte
func (*SignEncrypter) EncryptResume ¶
func (s *SignEncrypter) EncryptResume(r io.Reader, nonce signencrypt.Nonce, encKey signencrypt.SecretboxKey, signKey signencrypt.SignKey, verifyKey signencrypt.VerifyKey) (io.Reader, error)
EncryptResume is used to create a SignEncrypter to resume an interrupted attachment upload. It is *very* important that the keys passed in are not used to encrypt different plaintext than their original usage.
func (*SignEncrypter) EncryptWithNonce ¶
func (s *SignEncrypter) EncryptWithNonce(r io.Reader, nonce signencrypt.Nonce) (io.Reader, error)
func (*SignEncrypter) EncryptedLen ¶
func (s *SignEncrypter) EncryptedLen(size int) int
func (*SignEncrypter) SignKey ¶
func (s *SignEncrypter) SignKey() []byte
func (*SignEncrypter) VerifyKey ¶
func (s *SignEncrypter) VerifyKey() []byte
type StashKey ¶
type StashKey struct {
PlaintextHash []byte
ConversationID chat1.ConversationID
UserID keybase1.UID
}
func NewStashKey ¶
type Store ¶
type Store struct {
utils.DebugLabeler
// contains filtered or unexported fields
}
func (*Store) DecryptAsset ¶
func (*Store) DeleteAsset ¶
func (*Store) DeleteAssets ¶
func (*Store) DownloadAsset ¶
func (a *Store) DownloadAsset(ctx context.Context, params chat1.S3Params, asset chat1.Asset, w io.Writer, signer s3.Signer, progress types.ProgressReporter) error
DownloadAsset gets an object from S3 as described in asset.
func (*Store) GetAssetReader ¶
func (*Store) PutS3 ¶
func (a *Store) PutS3(ctx context.Context, r io.Reader, size int64, task *UploadTask, previous *AttachmentInfo) (*PutS3Result, error)
PutS3 uploads the data in Reader r to S3. It chooses whether to use putSingle or putMultiPipeline based on the size of the object.
func (*Store) UploadAsset ¶
type StreamSource ¶
type StreamSource struct {
chat1.LocalSource
// contains filtered or unexported fields
}
func NewStreamSource ¶
func NewStreamSource(s chat1.LocalSource) *StreamSource
func (*StreamSource) Basename ¶
func (s *StreamSource) Basename() string
func (*StreamSource) Close ¶
func (s *StreamSource) Close() error
func (*StreamSource) FileSize ¶
func (s *StreamSource) FileSize() int
func (*StreamSource) Open ¶
func (s *StreamSource) Open(sessionID int, cli *keybase1.StreamUiClient) (ReadResetter, error)
type UploadTask ¶
type UploadTask struct {
S3Params chat1.S3Params
Filename string
FileSize int
Plaintext ReadResetter
S3Signer s3.Signer
ConversationID chat1.ConversationID
UserID keybase1.UID
Progress types.ProgressReporter
// contains filtered or unexported fields
}
func (*UploadTask) Nonce ¶
func (u *UploadTask) Nonce() signencrypt.Nonce