Documentation ¶
Index ¶
- Constants
- Variables
- type PrivateKey
- func (privateKey *PrivateKey) Bytes() ([]byte, error)
- func (privateKey *PrivateKey) Decrypt(ciphertext []byte) (data []byte, err error)
- func (privateKey *PrivateKey) DecryptStream(dst io.Writer, src io.Reader) (err error)
- func (privateKey *PrivateKey) Encrypt(data []byte, compression bool) (ciphertext []byte, err error)
- func (privateKey *PrivateKey) EncryptStream(dst io.Writer, src io.Reader, compression bool) (err error)
- func (privateKey *PrivateKey) NewDecryptingReader(src io.Reader) (io.ReadCloser, error)
- func (privateKey *PrivateKey) NewEncryptingWriter(dst io.Writer, compression bool) (writer io.WriteCloser, err error)
- func (privateKey *PrivateKey) PublicKey() (*PublicKey, error)
- type PublicKey
- func (publicKey *PublicKey) Bytes() []byte
- func (publicKey *PublicKey) Encrypt(data []byte, compression bool) (ciphertext []byte, err error)
- func (publicKey *PublicKey) EncryptStream(dst io.Writer, src io.Reader, compression bool) (err error)
- func (publicKey *PublicKey) NewEncryptingWriter(dst io.Writer, compression bool) (writer io.WriteCloser, err error)
Constants ¶
const ( // PrivateKeyLength is the length of a private key. PrivateKeyLength = cipherKeyLength // PublicKeyLength is the length of a public key. PublicKeyLength = cipherKeyLength + kdfSpecLength // CipherTextMinLength is the minimum length of a ciphertext. CipherTextMinLength = symmcipher.CipherTextMinLength )
Variables ¶
var (
Version = "dev"
)
Functions ¶
This section is empty.
Types ¶
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
func NewPrivateKey ¶
func NewPrivateKey() (*PrivateKey, error)
NewPrivateKey creates a new random private key.
func NewPrivateKeyForPassword ¶
func NewPrivateKeyForPassword(password []byte) (*PrivateKey, error)
NewPrivateKeyForPassword creates a new private key for the given password.
func NewPrivateKeyForPasswordAndSpec ¶
func NewPrivateKeyForPasswordAndSpec(password []byte, iterations, memory, threads uint8) (*PrivateKey, error)
NewPrivateKeyForPasswordAndSpec creates a new private key for the given password and kdf spec.
func ParsePrivateKey ¶
func ParsePrivateKey(key []byte) (*PrivateKey, error)
ParsePrivateKey parses the given bytes and returns a corresponding private key. the given bytes must be 32 bytes long.
func (*PrivateKey) Bytes ¶
func (privateKey *PrivateKey) Bytes() ([]byte, error)
Bytes returns the private key as bytes only if it is not password based.
func (*PrivateKey) Decrypt ¶
func (privateKey *PrivateKey) Decrypt(ciphertext []byte) (data []byte, err error)
Decrypt decrypts the given ciphertext and returns the decrypted data.
func (*PrivateKey) DecryptStream ¶
DecryptStream decrypts src and writes to dst.
func (*PrivateKey) Encrypt ¶
func (privateKey *PrivateKey) Encrypt(data []byte, compression bool) (ciphertext []byte, err error)
Encrypt encrypts data with the private key treating it as a symmetric key.
func (*PrivateKey) EncryptStream ¶
func (privateKey *PrivateKey) EncryptStream(dst io.Writer, src io.Reader, compression bool) (err error)
EncryptStream encrypts src with the private key treating it as a symmetric key and writes to dst.
func (*PrivateKey) NewDecryptingReader ¶
func (privateKey *PrivateKey) NewDecryptingReader(src io.Reader) (io.ReadCloser, error)
func (*PrivateKey) NewEncryptingWriter ¶
func (privateKey *PrivateKey) NewEncryptingWriter(dst io.Writer, compression bool) (writer io.WriteCloser, err error)
func (*PrivateKey) PublicKey ¶
func (privateKey *PrivateKey) PublicKey() (*PublicKey, error)
PublicKey returns the public key corresponding to the private key.
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
func ParsePublicKey ¶
ParsePublicKey parses the given bytes and returns a corresponding public key. the given bytes must be 51 bytes long.
func (*PublicKey) EncryptStream ¶
func (publicKey *PublicKey) EncryptStream(dst io.Writer, src io.Reader, compression bool) (err error)
EncryptStream encrypts src with the public key and writes to dst.