cryptonic

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2022 License: MIT Imports: 15 Imported by: 1

README

cryptonic

Abstraction to crypto Library based on my crypto-textbook learning experiment

Documentation

Index

Constants

View Source
const (
	// Chiper Type to use: aesgcm, xchaha20poly1305
	//CHIPERTYPE = "aesgcm"
	CHIPERTYPE = "xchacha20poly1305"
	// Key Derivation: simple, pbkdf2, argon2
	KDFTYPE = "pkbdf2"
)
View Source
const (
	// SHA256
	AsymmetricHashSumSize = 32
)

Variables

This section is empty.

Functions

func AESDecrypt

func AESDecrypt(key, msg []byte) []byte

func AESEncrypt

func AESEncrypt(key, msg []byte) []byte

func Argon2iDeriveKey

func Argon2iDeriveKey(p, s []byte) []byte

Argon2i

func Argon2idDeriveKey

func Argon2idDeriveKey(p, s []byte) []byte

Argon2id

func AsymmetricDecrypt

func AsymmetricDecrypt(chipertext []byte, sk *rsa.PrivateKey) []byte

func AsymmetricEncrypt

func AsymmetricEncrypt(plaintext []byte, pk *rsa.PublicKey) []byte

Anonymous Public-Key Encryption

func AsymmetricOpen

func AsymmetricOpen(chipertext []byte, sk *rsa.PrivateKey, pk *rsa.PublicKey) []byte

Currently not implemented

func AsymmetricSeal

func AsymmetricSeal(plaintext []byte, pk *rsa.PublicKey, sk *rsa.PrivateKey) []byte

Currently not implemented

func AsymmetricSign

func AsymmetricSign(message []byte, sk *rsa.PrivateKey) []byte

AsymmetricSign return a byte stream with hashsum and signature concat

func AsymmetricSignWithHash

func AsymmetricSignWithHash(message []byte, sk *rsa.PrivateKey) ([]byte, []byte)

func AsymmetricVerify

func AsymmetricVerify(message []byte, pk *rsa.PublicKey, signature []byte) bool

func AsymmetricVerifyWithHash

func AsymmetricVerifyWithHash(message []byte, pk *rsa.PublicKey, signature, hash []byte) bool

func Decrypt

func Decrypt(chiper string, key, msg []byte) []byte

func DeriveKey

func DeriveKey(derivetype, passphrase, salt string) []byte

Derive Key Main Function

func Encrypt

func Encrypt(chiper string, key, msg []byte) []byte

func KeyDerive

func KeyDerive(passphrase string) []byte

Simple API

func Nonce

func Nonce(size int) []byte

func Open

func Open(chipertext, secret string) (plaintext string)

func PKBDF2DeriveKey

func PKBDF2DeriveKey(p, s []byte) []byte

### PKBDF2

func PWCheck

func PWCheck(pw, pwc, salt string) bool

func PWHash

func PWHash(pass, salt string) string

func RSADencrypt

func RSADencrypt(key *rsa.PrivateKey, msg []byte) []byte

func RSAEncrypt

func RSAEncrypt(key *rsa.PublicKey, msg []byte) []byte

### RSA En-/Decription

func RSAGenKeyPair

func RSAGenKeyPair(keySize int) (*rsa.PrivateKey, *rsa.PublicKey)

func RSAReadEncryptedPrivateKey

func RSAReadEncryptedPrivateKey(fn, p string) *rsa.PrivateKey

func RSAReadKeyPair

func RSAReadKeyPair(filebasename string, passphrase string) (sk *rsa.PrivateKey, pk *rsa.PublicKey)

func RSAReadPrivateKey

func RSAReadPrivateKey(fn string) *rsa.PrivateKey

func RSAReadPublicKey

func RSAReadPublicKey(fn string) *rsa.PublicKey

func RSARenGenPubKey

func RSARenGenPubKey(filebasename string, passphrase string)

#ISSUE if you your privkey is encrypted and you regen pub key with option uncrypted this leads to an empty pubkey Won't fix cause no data loose and you can simply regen pub key anyway.

func RSASign

func RSASign(key *rsa.PrivateKey, msg []byte) (msgHashSum, sig []byte)

### RSA Sign and Verify

func RSAVerify

func RSAVerify(key *rsa.PublicKey, msgHashSum, sig []byte) bool

func RSAWriteEncryptedPricvateKey

func RSAWriteEncryptedPricvateKey(fn string, p string, v interface{}) error

func RSAWriteKey

func RSAWriteKey(fn string, v interface{}) error

func RSAWriteKeyPair

func RSAWriteKeyPair(filebasename string, priv *rsa.PrivateKey, pub *rsa.PublicKey, passphrase string)

func RandomString

func RandomString(size int) string

func Salt

func Salt(size int) string

func Seal

func Seal(plaintext, secret string) (chipertext string)

func SymmetricOpen

func SymmetricOpen(chipertext, key []byte) []byte

func SymmetricSeal

func SymmetricSeal(plaintext, key []byte) []byte

Use AEAD Terminology Seal == Encrypte and Open == Decrypt

func XCPDecrypt

func XCPDecrypt(key, msg []byte) []byte

func XCPEncrypt

func XCPEncrypt(key, msg []byte) []byte

## XChacha20poly1305

Types

type RSAEncryptedPrivateKey

type RSAEncryptedPrivateKey struct {
	Chiper     string
	KDF        string
	Salt       string
	Privatekey []byte
}

Jump to

Keyboard shortcuts

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