Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- func (c Config) Decrypt(out, data []byte, priv PrivateKey, pub PublicKey) error
- func (c Config) DecryptedLen(data int) int
- func (c Config) Encrypt(out, data []byte, priv PrivateKey, pub PublicKey) error
- func (c Config) EncryptedLen(data int) int
- func (c Config) GenerateKey() (priv PrivateKey, err error)
- func (c Config) PaddingLen(data int) int
- type Mode
- type PrivateKey
- type PublicKey
Constants ¶
const ( // KeyLen is the length of a key generated by this package, be it // public or private. KeyLen = 32 )
Variables ¶
var ( ErrDataLen = errors.New("data length zero or not a multiple of the blocksize") ErrOutLen = errors.New("out length is too small") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Rand is the random source to use. If it is nil, // crypto/rand.Reader is used. Rand io.Reader // Mode is the encryption mode to use for the symmetric encryption // step. If it is nil, AES is used. Mode Mode }
Config handles configuration details for a variety of things.
func (Config) Decrypt ¶
func (c Config) Decrypt(out, data []byte, priv PrivateKey, pub PublicKey) error
Decrypt decrypts data using a key generated via ECDH from the provided public and private Ed25519 keys.
If the length of data is zero or not a multiple of the symmetric encryption's blocksize, ErrDataLen is returned.
If the length of data is not at least c.DecryptedLen(len(data)), ErrOutLen is returned.
func (Config) DecryptedLen ¶
DecryptedLen returns the minimum number of bytes that are required to store data of the given length, including padding, after decryption.
func (Config) Encrypt ¶
func (c Config) Encrypt(out, data []byte, priv PrivateKey, pub PublicKey) error
Encrypt encrypts data using a key generated via ECDH from the provided public and private Ed25519 keys.
If the length of data is not at least c.EncryptedLen(len(data)), ErrOutLen is returned.
func (Config) EncryptedLen ¶
EncryptedLen returns the minimum number of bytes that are required to store data of the given length after encryption.
func (Config) GenerateKey ¶
func (c Config) GenerateKey() (priv PrivateKey, err error)
GenerateKey generates a new private key from the provided source of random bytes.
func (Config) PaddingLen ¶
PaddingLen returns the number of bytes of padding that will be generated for data of the given length when encrypting.
type Mode ¶
type Mode interface {
// contains filtered or unexported methods
}
Mode represents the symmetric encryption scheme to be used.
type PrivateKey ¶
type PrivateKey []byte
func (PrivateKey) PublicKey ¶
func (priv PrivateKey) PublicKey() (PublicKey, error)
PublicKey calculates a public key from a given private key.