appsec

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppPrivateKey *rsa.PrivateKey
View Source
var AppPublicKey *rsa.PublicKey

Functions

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 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 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 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 PEM certificate 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