cryptoutil

package
v0.0.72 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: BSD-3-Clause Imports: 9 Imported by: 1

Documentation

Overview

Package cryptoutil provides utility functions for cryptographic operations. It is the consumer's responsibility to ensure that inputs are reasonably sized so as to avoid memory exhaustion attacks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptSymmetricAESGCM added in v0.0.68

func DecryptSymmetricAESGCM(encryptedMsg []byte, secretKey *[32]byte) ([]byte, error)

DecryptSymmetricAESGCM decrypts a message using AES-256-GCM.

func DecryptSymmetricXChaCha20Poly1305 added in v0.0.68

func DecryptSymmetricXChaCha20Poly1305(encryptedMsg []byte, secretKey *[32]byte) ([]byte, error)

DecryptSymmetricXChaCha20Poly1305 decrypts a message using XChaCha20-Poly1305.

func EncryptSymmetricAESGCM added in v0.0.68

func EncryptSymmetricAESGCM(msg []byte, secretKey *[32]byte) ([]byte, error)

EncryptSymmetricAESGCM encrypts a message using AES-256-GCM.

func EncryptSymmetricXChaCha20Poly1305 added in v0.0.68

func EncryptSymmetricXChaCha20Poly1305(msg []byte, secretKey *[32]byte) ([]byte, error)

EncryptSymmetricXChaCha20Poly1305 encrypts a message using XChaCha20-Poly1305.

func Sha256Hash added in v0.0.60

func Sha256Hash(msg []byte) []byte

Sha256Hash returns the SHA-256 hash of a message as a byte slice.

func SignSymmetric added in v0.0.12

func SignSymmetric(msg []byte, secretKey *[32]byte) ([]byte, error)

SignSymmetric signs a message using a symmetric key. It is a convenience wrapper around the nacl/auth package, which uses HMAC-SHA-512-256.

func VerifyAndReadAsymmetric added in v0.0.68

func VerifyAndReadAsymmetric(signedMsg []byte, publicKey *[32]byte) ([]byte, error)

VerifyAndReadAsymmetric verifies a signed message using an Ed25519 public key and returns the original message.

func VerifyAndReadAsymmetricBase64 added in v0.0.68

func VerifyAndReadAsymmetricBase64(signedMsg Base64, publicKey Base64) ([]byte, error)

VerifyAndReadAsymmetricBase64 verifies a signed message using a base64 encoded Ed25519 public key and returns the original message.

func VerifyAndReadSymmetric added in v0.0.20

func VerifyAndReadSymmetric(signedMsg []byte, secretKey *[32]byte) ([]byte, error)

VerifyAndReadSymmetric verifies a signed message using a symmetric key and returns the original message. It is a convenience wrapper around the nacl/auth package, which uses HMAC-SHA-512-256.

Types

type Base64 added in v0.0.57

type Base64 = string

Jump to

Keyboard shortcuts

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