crypto

package
v0.0.0-...-fc872c1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2015 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package crypto is used for encyption of bytes This is TOY encryption and keep the RSA privatekey next to the encrypted AES key. The private key should be stored someone a bit more secure. ;)

Current version: experimental

Index

Constants

This section is empty.

Variables

View Source
var CertifcatePath = filepath.Join(os.TempDir(), "blocker", "cert.pem")

Path to the certificate

View Source
var KeyPath = filepath.Join(os.TempDir(), "blocker", "key.pem")

Path to the private key

Functions

func AesCfbDecrypt

func AesCfbDecrypt(encryptedBytes []byte, hash string) ([]byte, error)

Encrpyt data using AES with the CFB chipher mode

func AesCfbEncrypt

func AesCfbEncrypt(bytesToEncrypt []byte, hash string) ([]byte, error)

Encrpyt data using AES with the CFB chipher mode

func DeleteAesSecret

func DeleteAesSecret(hash string)

DeleteAesSecret - Remove a key if not needed

func GenerateAesSecret

func GenerateAesSecret() []byte

Create a new Aes Secret

func GenerateRsaKey

func GenerateRsaKey()

Generate a new key

func GetAesSecretPath

func GetAesSecretPath(hash string) string

GetAesSecretPath - Will return a key name for a hash

func LoadOrGenerateRsaKey

func LoadOrGenerateRsaKey()

Load or Generate a RSA certiciate

func RsaDecrypt

func RsaDecrypt(encryptedBytes []byte) ([]byte, error)

Decrypt data using RSA and a private key

func RsaEncrypt

func RsaEncrypt(bytesToEncrypt []byte) ([]byte, error)

Encrypt data using RSA and a public key

Types

type AesKey

type AesKey struct {
	// contains filtered or unexported fields
}

Structure to hold unencrypted AES key

func GetAesSecret

func GetAesSecret(hash string) (AesKey, error)

Get the AES secret to be used for encryption

type RsaChipher

type RsaChipher struct {
	PrivateKey     *rsa.PrivateKey
	PrivateKeyPath string
	PublicKey      *rsa.PublicKey
	PublicKeyPath  string
}

Structure for encryption chipher

var RsaEncryptionChipher RsaChipher

The key to be used to encrypt and decrypt when using RSA encryption

Jump to

Keyboard shortcuts

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