appsec

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: MIT Imports: 17 Imported by: 2

README

Appsec

Common/frequently used security related go libraries for application development.

Getting started

Use standard go package installation/import to include the package in your application

>> go get github.com/berrypay/appsec

License

This go modules are licensed under MIT

Project Status

This project is under active development

Contributing

If you have any questions, you can give Issues, or you can also directly start Pull Requests(but we recommend giving issues first to communicate with the teams).

Documentation

Index

Constants

View Source
const INVALID_AES_KEY_LENGTH = "invalid AES key length. Expected 32 bytes, got %d bytes"

Variables

View Source
var AESSecretKey []byte
View Source
var AppPrivateKey *rsa.PrivateKey
View Source
var AppPublicKey *rsa.PublicKey

Functions

func Adler32 added in v1.0.5

func Adler32(b []byte) uint32

func ComputeHMAC256

func ComputeHMAC256(message string, secret string) string

ComputeHMAC256 computes HMAC256 signature of the message using the given secret parameters: message string, secret string return: base64 encoded HMAC256 signature

func ComputeHMAC512

func ComputeHMAC512(message string, secret string) string

ComputeHMAC512 computes HMAC512 signature of the message using the given secret parameters: message string, secret string return: base64 encoded HMAC512 signature

func Crc32Castagnoli added in v1.0.5

func Crc32Castagnoli(b []byte) uint32

func Crc32IEEE added in v1.0.5

func Crc32IEEE(b []byte) uint32

func Crc32Koopman added in v1.0.5

func Crc32Koopman(b []byte) uint32

func Crc64ECMA added in v1.0.5

func Crc64ECMA(b []byte) uint64

func Crc64ISO added in v1.0.5

func Crc64ISO(b []byte) uint64

func DecryptAESGCM added in v1.1.0

func DecryptAESGCM(cipherText []byte) ([]byte, error)

func DecryptOAEP

func DecryptOAEP(cipher string, label string) (string, error)

Decrypt decrypts the given base64 encoded RSA-OAEP cipher text using the AppKey, SHA256 hash function

Returns the plain text string

The label parameter must match the value given when encrypting

func EncryptAESGCM added in v1.1.0

func EncryptAESGCM(secret []byte) ([]byte, error)

func EncryptOAEP

func EncryptOAEP(secret string, label string) (string, error)

Encrypt encrypts the given secret string with RSA-OAEP using the AppKey, SHA256 hash function and specified label

Returns the base64 encoded cipher text

func InitAES added in v1.1.0

func InitAES(key []byte) error

func IsMatchedHMAC256

func IsMatchedHMAC256(signature string, message string, secret string) bool

IsMatchedHMAC256 compares HMAC256 signature between the given signature to the computed signature based on given message and secret parameters: signature string, message string, secret string return: true if matched, false otherwise

func IsMatchedHMAC512

func IsMatchedHMAC512(signature string, message string, secret string) bool

IsMatchedHMAC512 compares HMAC512 signature between the given signature to the computed signature based on given message and secret parameters: signature string, message string, secret string return: true if matched, false otherwise

func LoadPrivateKey

func LoadPrivateKey(path string) error

LoadPrivateKey loads the public key from the given PKCS8 PEM encoded key file

If the argument path is empty, the default app.key file on the same directory of executable is assumed to be used

func LoadPublicKey

func LoadPublicKey(path string) error

LoadPublicKey loads the public key from the given PEM certificate file

If the argument path is empty, the default app.crt file on the same directory of executable is assumed to be used

Types

type MACAlgo

type MACAlgo string
const (
	HMAC_256 MACAlgo = "HMAC256"
	HMAC_512 MACAlgo = "HMAC512"
)

Jump to

Keyboard shortcuts

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