bc

package
v0.0.0-...-b65cb46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2019 License: MIT Imports: 22 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(ciphertext, aesKey []byte) ([]byte, error)

AesDecrypt : Decrypt some bytes with a given key using AES-CBC-aes.BlockSize

func AesEncrypt

func AesEncrypt(clear, aesKey []byte) ([]byte, error)

AesEncrypt : Encrypt some bytes with a given key using AES-CBC-aes.BlockSize

func EncryptFile

func EncryptFile(clearfile string, outfile string, aesKey []byte) error

EncryptFile will encrypt clearfile with aesKey and save it to outfile

func GenerateRandomBytes

func GenerateRandomBytes(count int) ([]byte, error)

GenerateRandomBytes : Generates as many random bytes as you ask for, returns them as []byte

func GenerateSSLCert

func GenerateSSLCert(certfile string, keyfile string, eccMode bool) error

GenerateSSLCert : Generate you some SSL cert/key

func GenerateSSLCertBytes

func GenerateSSLCertBytes(eccMode bool) ([]byte, []byte, error)

GenerateSSLCertBytes : Generate you some SSL cert/key bytes

func InitSSL

func InitSSL(certfile string, keyfile string, useECC bool) error

InitSSL : Generate you some SSL cert/key, only if the named files don't exist

func Kdf

func Kdf(key []byte, label, salt []byte) ([]byte, error)

Kdf : Key derivation function

func OpenAndDecrypt

func OpenAndDecrypt(filename string, fileType string, aesKey []byte) (vfs.VFS, error)

OpenAndDecrypt returns an in-memory VFS initialized with the contents of the given filename, which will be decrypted with the given AES key,

and which must have one of the following fileTypes:

- .zip
- .tar
- .tar.gz
- .tar.bz2

func Pkcs7Pad

func Pkcs7Pad(data []byte, blocklen int) ([]byte, error)

Pkcs7Pad : Appends padding, PKCS-7 style

func Pkcs7Unpad

func Pkcs7Unpad(data []byte, blocklen int) ([]byte, error)

Pkcs7Unpad : Returns slice of the original data without padding.

func SaveAndEncrypt

func SaveAndEncrypt(fs vfs.VFS, outfile string, fileType string, aesKey []byte) error

SaveAndEncrypt converts the given VFS to the given archive type, and then encrypts the archive with the given AES key. Supported fileTypes:

  • .zip
  • .tar
  • .tar.gz TODO: NOT SUPPORTED - .tar.bz2

Types

type KeyPair

type KeyPair interface {
	GenerateKey()
	Precompute()

	ToB64() string
	FromB64(s string) error

	EncryptMessage(clear []byte, pubkey PubKey) ([]byte, error)
	DecryptMessage(data []byte) (bool, []byte, error)

	GetName() string
	GetPubKey() PubKey

	ValidatePubKey(s string) bool

	Clone() KeyPair
}

KeyPair : Interface to implement to make a bencrypt-compatable cryptosystem

type PubKey

type PubKey interface {
	ToB64() string
	FromB64(s string) error

	ToBytes() []byte
	FromBytes([]byte) error

	Clone() PubKey
	Nil() interface{}
}

PubKey : Interface to implement to make a bencrypt-compatable Public Key

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL