Documentation ¶
Index ¶
- Variables
- func ReplaceKeys(w io.Writer, r io.Reader, replace ReplaceFn, o ReplaceKeysOptions) error
- type Reader
- func (r *Reader) DebugStream(w io.Writer) error
- func (r *Reader) NextStream() (*Stream, error)
- func (r *Reader) PrivateKeyProvider(fn func(key *rsa.PublicKey) *rsa.PrivateKey)
- func (r *Reader) ReturnNonDecryptable(b bool)
- func (r *Reader) SetPrivateKey(k *rsa.PrivateKey)
- func (r *Reader) SkipEncrypted(b bool)
- type ReplaceFn
- type ReplaceKeysOptions
- type Stream
- type Writer
- func (w *Writer) AddEncryptedStream(name string, extra []byte) (io.WriteCloser, error)
- func (w *Writer) AddError(msg string) error
- func (w *Writer) AddKeyEncrypted(publicKey *rsa.PublicKey) error
- func (w *Writer) AddKeyPlain() error
- func (w *Writer) AddUnencryptedStream(name string, extra []byte) (io.WriteCloser, error)
- func (w *Writer) Close() error
Constants ¶
This section is empty.
Variables ¶
var ErrNoKey = errors.New("no valid private key found")
ErrNoKey is returned when a stream cannot be decrypted. The Skip function on the stream can be called to skip to the next.
Functions ¶
func ReplaceKeys ¶
ReplaceKeys will replace the keys in a stream.
A replace function must be provided. See ReplaceFn for functionality. If encryptAll is set.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func (*Reader) DebugStream ¶
DebugStream will print stream block information to w.
func (*Reader) NextStream ¶
NextStream will return the next stream. Before calling this the previous stream must be read until EOF, or Skip() should have been called. Will return nil, io.EOF when there are no more streams.
func (*Reader) PrivateKeyProvider ¶
func (r *Reader) PrivateKeyProvider(fn func(key *rsa.PublicKey) *rsa.PrivateKey)
PrivateKeyProvider will ask for a private key matching the public key. If the function returns a nil private key the stream key will not be decrypted and if SkipEncrypted has been set any streams with this key will be silently skipped. This overrides any key set by SetPrivateKey.
func (*Reader) ReturnNonDecryptable ¶
ReturnNonDecryptable will return non-decryptable stream headers. Streams are returned with ErrNoKey error. Streams with this error cannot be read, but the Skip function can be invoked. SkipEncrypted overrides this.
func (*Reader) SetPrivateKey ¶
func (r *Reader) SetPrivateKey(k *rsa.PrivateKey)
SetPrivateKey will set the private key to allow stream decryption. This overrides any function set by PrivateKeyProvider.
func (*Reader) SkipEncrypted ¶
SkipEncrypted will skip encrypted streams if no private key has been set.
type ReplaceFn ¶
ReplaceFn provides key replacement.
When a key is found on stream, the function is called with the public key. The function must then return a private key to decrypt matching the key sent. The public key must then be specified that should be used to re-encrypt the stream.
If no private key is sent and the public key matches the one sent to the function the key will be kept as is. Other returned values will cause an error.
For encrypting unencrypted keys on stream a nil key will be sent. If a public key is returned the key will be encrypted with the public key. No private key should be returned for this.
type ReplaceKeysOptions ¶
type ReplaceKeysOptions struct { // If EncryptAll set all unencrypted keys will be encrypted. EncryptAll bool // PassErrors will pass through error an error packet, // and not return an error. PassErrors bool }
ReplaceKeysOptions allows passing additional options to ReplaceKeys.
type Stream ¶
type Stream struct { io.Reader Name string Extra []byte SentEncrypted bool // contains filtered or unexported fields }
Stream returns the next stream.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer provides a stream writer. Streams can optionally be encrypted. All streams have checksum verification.
func NewWriter ¶
NewWriter will return a writer that allows to add encrypted and non-encrypted data streams.
func (*Writer) AddEncryptedStream ¶
AddEncryptedStream adds a named encrypted stream. AddKeyEncrypted must have been called before this, but multiple streams can safely use the same key. Extra data can be added, which is added without encryption or checksums.
func (*Writer) AddError ¶
AddError will indicate the writer encountered an error and the reader should abort the stream. The message will be returned as an error.
func (*Writer) AddKeyEncrypted ¶
AddKeyEncrypted will create a new encryption key and add it to the stream. The key will be encrypted with the public key provided. All following files will be encrypted with this key.
func (*Writer) AddKeyPlain ¶
AddKeyPlain will create a new encryption key and add it to the stream. The key will be stored without any encryption. All calls to AddEncryptedStream will use this key
func (*Writer) AddUnencryptedStream ¶
AddUnencryptedStream adds a named stream. Extra data can be added, which is added without encryption or checksums.