Documentation
¶
Overview ¶
Package storecrypto defines the versioned, client-side encrypted format used by croc's asynchronous stored transfers.
Index ¶
- Constants
- func CapabilityVerifier(capability []byte) []byte
- func DecodeBase64URL(value string) ([]byte, error)
- func EncodeBase64URL(value []byte) string
- func EncodedSHA256(data []byte) string
- func GenerateKey() ([]byte, error)
- func GenerateTransferID() (string, error)
- func OpenChunk(master []byte, id string, ref ChunkRef, ciphertext []byte) ([]byte, error)
- func OpenManifestJSON(master []byte, id string, ciphertext []byte, maxBytes int64) ([]byte, error)
- func RedeemCapability(master []byte) ([]byte, error)
- func SealChunk(master []byte, id string, ref ChunkRef, plaintext []byte) ([]byte, error)
- func SealManifest(master []byte, id string, manifest Manifest) ([]byte, error)
- func SealManifestJSON(master []byte, id string, plaintext []byte) ([]byte, error)
- func ValidateManifest(manifest Manifest, maxBytes int64) error
- type ChunkCipher
- func (c *ChunkCipher) NonceSize() int
- func (c *ChunkCipher) Open(dst []byte, id string, ref ChunkRef, ciphertext []byte) ([]byte, error)
- func (c *ChunkCipher) OpenInPlace(id string, ref ChunkRef, ciphertext []byte) ([]byte, error)
- func (c *ChunkCipher) Seal(dst []byte, id string, ref ChunkRef, plaintext []byte) ([]byte, error)
- func (c *ChunkCipher) SealInPlace(buffer []byte, id string, ref ChunkRef) ([]byte, error)
- type ChunkRef
- type Manifest
- type ManifestFile
- type Share
Constants ¶
const ( Version = 1 Protocol = "croc-store-v1" ChunkSize = 4 * 1024 * 1024 KeySize = 32 TransferIDLen = 16 MaxFiles = 100 )
Variables ¶
This section is empty.
Functions ¶
func CapabilityVerifier ¶
CapabilityVerifier returns the value stored by the service for a capability.
func DecodeBase64URL ¶
DecodeBase64URL decodes a protocol byte string.
func EncodeBase64URL ¶
EncodeBase64URL encodes a protocol byte string.
func EncodedSHA256 ¶
EncodedSHA256 returns an unpadded URL-safe digest.
func GenerateKey ¶
GenerateKey returns a fresh 256-bit transfer key.
func GenerateTransferID ¶
GenerateTransferID returns a URL-safe identifier containing 128 bits of entropy. Identifiers are public and are not decryption keys.
func OpenManifestJSON ¶
OpenManifestJSON authenticates and decrypts a manifest, returning its validated JSON representation.
func RedeemCapability ¶
RedeemCapability derives a capability that authorizes reading ciphertext but cannot decrypt it.
func SealManifest ¶
SealManifest encrypts a validated manifest.
func SealManifestJSON ¶
SealManifestJSON validates and encrypts a JSON-encoded manifest.
func ValidateManifest ¶
ValidateManifest rejects malformed or unsafe metadata before any files are created by a receiver.
Types ¶
type ChunkCipher ¶
type ChunkCipher struct {
// contains filtered or unexported fields
}
ChunkCipher reuses the derived data key and AEAD across chunks in one transfer. It also supports caller-owned output buffers for the hot path.
func NewChunkCipher ¶
func NewChunkCipher(master []byte) (*ChunkCipher, error)
NewChunkCipher prepares the data cipher for a stored transfer.
func (*ChunkCipher) NonceSize ¶
func (c *ChunkCipher) NonceSize() int
NonceSize returns the prefix reserved before plaintext for SealInPlace.
func (*ChunkCipher) OpenInPlace ¶
OpenInPlace authenticates and decrypts into ciphertext's payload area.
func (*ChunkCipher) SealInPlace ¶
SealInPlace encrypts plaintext already stored immediately after the nonce prefix in buffer. The ciphertext overwrites that plaintext.
type ChunkRef ¶
ChunkRef identifies a chunk and supplies the authenticated context required to decrypt it.
type Manifest ¶
type Manifest struct {
Version int `json:"v"`
ChunkSize int `json:"cs"`
Files []ManifestFile `json:"f"`
}
Manifest is encrypted before it is uploaded. The storage service never sees file names, modification times, sizes, or hashes.
type ManifestFile ¶
type ManifestFile struct {
Name string `json:"n"`
Size int64 `json:"s"`
Modified time.Time `json:"m"`
SHA256 string `json:"h"`
FirstChunk int `json:"fc"`
ChunkCount int `json:"cc"`
}
ManifestFile describes one regular file in a stored transfer.
type Share ¶
type Share struct {
}
Share contains the public storage origin, opaque object ID, and secret master key encoded by a browser URL or CLI token.
func ParseShare ¶
ParseShare parses either the canonical browser URL or the CLI token.
func (Share) BrowserURL ¶
BrowserURL formats a share as a browser-safe fragment URL.