berty: Index | Files

package cryptoutil

import ""

Package cryptoutil contains generic & stateless crypto helpers.


Package Files

cryptoutil.go doc.go


const (
    KeySize          = 32 // Key size required by box
    NonceSize        = 24 // Nonce size required by box
    ScryptIterations = 1 << 15
    ScryptR          = 8
    ScryptP          = 1
    ScryptKeyLen     = 32

func AESCTRStream Uses

func AESCTRStream(key, iv []byte) (cipher.Stream, error)

AESCTRStream returns a CTR stream that can be used to produce ciphertext without padding.

func AESGCMDecrypt Uses

func AESGCMDecrypt(key, data []byte) ([]byte, error)

AESGCMDecrypt uses AES+GCM to decrypt plaintext data.

func AESGCMEncrypt Uses

func AESGCMEncrypt(key, data []byte) ([]byte, error)

AESGCMEncrypt use AES+GCM to encrypt plaintext data.

The generated output will be longer than the original plaintext input.

func ConcatAndHashSha256 Uses

func ConcatAndHashSha256(slices ...[]byte) *[sha256.Size]byte

func DeriveKey Uses

func DeriveKey(passphrase, salt []byte) ([]byte, []byte, error)

DeriveKey takes a passphrase of any length and returns a key of fixed size.

If no salt is provided, a new one will be created and returned.

func EdwardsToMontgomery Uses

func EdwardsToMontgomery(privKey crypto.PrivKey, pubKey crypto.PubKey) (*[32]byte, *[32]byte, error)

EdwardsToMontgomery converts ed25519 priv/pub keys to X25519 keys.

func EdwardsToMontgomeryPriv Uses

func EdwardsToMontgomeryPriv(privKey crypto.PrivKey) (*[KeySize]byte, error)

EdwardsToMontgomeryPriv converts ed25519 priv key to X25519 priv key.

func EdwardsToMontgomeryPub Uses

func EdwardsToMontgomeryPub(pubKey crypto.PubKey) (*[KeySize]byte, error)

EdwardsToMontgomeryPub converts ed25519 pub key to X25519 pub key.

func GenerateNonce Uses

func GenerateNonce() (*[NonceSize]byte, error)

func GenerateNonceSize Uses

func GenerateNonceSize(size int) ([]byte, error)

func KeySliceToArray Uses

func KeySliceToArray(keySlice []byte) (*[KeySize]byte, error)

func NonceSliceToArray Uses

func NonceSliceToArray(nonceSlice []byte) (*[NonceSize]byte, error)

func SeedFromEd25519PrivateKey Uses

func SeedFromEd25519PrivateKey(key crypto.PrivKey) ([]byte, error)

Package cryptoutil imports 11 packages (graph). Updated 2021-01-07. Refresh now. Tools for package owners.