cryptography

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

README

Cryptography

Wrappers around Go cryptographic functions, you should avoid using any cryptographic primitives that are not from this package.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidKeyLength - Invalid key length
	ErrInvalidKeyLength = errors.New("invalid length")

	// ErrReplayAttack - Replay attack
	ErrReplayAttack = errors.New("replay attack detected")

	// ErrDecryptFailed
	ErrDecryptFailed = errors.New("decryption failed")
)

Functions

func AgeDecrypt

func AgeDecrypt(recipientPrivateKey string, ciphertext []byte) ([]byte, error)

AgeDecrypt - Decrypt using Curve 25519 + ChaCha20Poly1305

func AgeEncrypt

func AgeEncrypt(recipientPublicKey string, plaintext []byte) ([]byte, error)

AgeEncrypt - Encrypt using Nacl Box

func AgeKeyExFromImplant

func AgeKeyExFromImplant(serverPrivateKey string, implantPrivateKey string, ciphertext []byte) ([]byte, error)

AgeKeyPairFromImplant - Decrypt the session key from an implant

func Decrypt

func Decrypt(key [chacha20poly1305.KeySize]byte, ciphertext []byte) ([]byte, error)

Decrypt - Decrypt using chacha20poly1305 https://pkg.go.dev/golang.org/x/crypto/chacha20poly1305

func Encrypt

func Encrypt(key [chacha20poly1305.KeySize]byte, plaintext []byte) ([]byte, error)

Encrypt - Encrypt using chacha20poly1305 https://pkg.go.dev/golang.org/x/crypto/chacha20poly1305

func KeyFromBytes

func KeyFromBytes(data []byte) ([chacha20poly1305.KeySize]byte, error)

KeyFromBytes - Convert to fixed length buffer

func MinisignServerPrivateKey

func MinisignServerPrivateKey() *minisign.PrivateKey

MinisignServerPrivateKey - Get the server's minisign key pair

func MinisignServerPublicKey

func MinisignServerPublicKey() string

MinisignServerPublicKey - Get the server's minisign public key string

func MinisignServerSign

func MinisignServerSign(message []byte) string

MinisignServerSign - Sign a message with the server's minisign private key

func PreludeDecrypt

func PreludeDecrypt(data []byte, key []byte) []byte

PreludeDecrypt a command

func PreludeEncrypt

func PreludeEncrypt(data []byte, key []byte, iv []byte) []byte

PreludeEncrypt the results

func ProcessPEM

func ProcessPEM(filepath string) (string, error)

func RC4EncryptUnsafe

func RC4EncryptUnsafe(data []byte, key []byte) []byte

RC4 encryption - Cryptographically insecure! Added for stage-listener shellcode obfuscation Dont use for anything else!

func RandomSymmetricKey

func RandomSymmetricKey() [chacha20poly1305.KeySize]byte

RandomSymmetricKey - Generate random ID of randomIDSize bytes

Types

type AgeKeyPair

type AgeKeyPair struct {
	Public  string `json:"public"`
	Private string `json:"private"`
}

AgeKeyPair - Holds the public/private key pair

func AgeServerKeyPair

func AgeServerKeyPair() *AgeKeyPair

AgeServerKeyPair - Get teh server's ECC key pair

func RandomAgeKeyPair

func RandomAgeKeyPair() (*AgeKeyPair, error)

RandomAgeKeyPair - Generate a random Curve 25519 key pair

func (*AgeKeyPair) PrivateKey

func (e *AgeKeyPair) PrivateKey() string

PrivateBase64 - Base64 encoded private key

func (*AgeKeyPair) PublicKey

func (e *AgeKeyPair) PublicKey() *age.X25519Recipient

PublicKey - Return the parsed public key

type CipherContext

type CipherContext struct {
	Key [chacha20poly1305.KeySize]byte
	// contains filtered or unexported fields
}

CipherContext - Tracks a series of messages encrypted under the same key and detects/prevents replay attacks.

func NewCipherContext

func NewCipherContext(key [chacha20poly1305.KeySize]byte) *CipherContext

NewCipherContext - Wrapper around creating a cipher context from a key

func (*CipherContext) Decrypt

func (c *CipherContext) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt - Decrypt a message with the contextual key and check for replay attacks

func (*CipherContext) Encrypt

func (c *CipherContext) Encrypt(plaintext []byte) ([]byte, error)

Encrypt - Encrypt a message with the contextual key

Directories

Path Synopsis
Package minisign implements the minisign signature scheme.
Package minisign implements the minisign signature scheme.

Jump to

Keyboard shortcuts

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