...

Package encryption

import "github.com/Diarkis/diarkis/encryption"
Overview
Index

Overview ▾

func Auth

func Auth(mackey []byte, signature []byte, data []byte) bool

Auth Authenticates a signed payload w/ mac key and signature

func AuthAndDecrypt

func AuthAndDecrypt(key []byte, iv []byte, mackey []byte, data []byte) ([]byte, error)

AuthAndDecrypt Authenticates the payload and decrypts it

func CreateKey

func CreateKey() ([]byte, error)

CreateKey Creates key for encryption/decryption - NOTE: create key, iv and, mackey with this

func CreateSid

func CreateSid() ([]byte, error)

CreateSid Creates a session ID to manage encryption keys and its data

func Decrypt

func Decrypt(key []byte, iv []byte, size int, data []byte) ([]byte, error)

Decrypt Decrypts an encrypted payload

func Encrypt

func Encrypt(key []byte, iv []byte, data []byte) ([]byte, error)

Encrypt Encrypts a payload - NOTE: key must be unique and secure

func EncryptAndSign

func EncryptAndSign(key []byte, iv []byte, mackey []byte, data []byte) ([]byte, error)

EncryptAndSign Encrypts the payload and signs it

func KeyToString

func KeyToString(key []byte) (string, error)

KeyToString Converts a byte array key to a string

func Sign

func Sign(mackey []byte, data []byte)

Sign Signs a payload and creates a 32 byte-long signature and copies it

func StringToKey

func StringToKey(str string) ([]byte, error)

StringToKey Converts the string given to a byte array key