security

package
v0.0.0-...-725c2af Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: MPL-2.0 Imports: 10 Imported by: 7

README

#security

The package provides the following public functions:

  • AuthenticateGroup- Takes a group name (string) and key (string), plus a pointer to cfg.Security.Groups. Returns a boolean indicating whether or not the group and key match a pair of values within the config's Groups.
  • EncodeHMAC- Takes a group's hmackey (string), a raw message to be encoded (string), and the current timestamp. It returns the encoded message ([]byte) using the group's HMAC key. Note that the decrypt function will only work if the encrypted message is decrypted within 30 seconds of the set timestamp, otherwise the payload is expired and an error will be returned.
  • DecodeHMAC- Takes a group's key (string) and the encoded message ([]byte). It returns the decoded message (string). Note that this decrypt function will only work if the encrypted message is decrypted within 30 seconds of the set timestamp, otherwise the payload is expired and an error will be returned.

Documentation

Overview

Package security provides functions for group authentication and HMAC encryption/decryption

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthenticateGroup

func AuthenticateGroup(group string, key string, groups *[]config.SecurityGroups) (authenticated bool)

AuthenticateGroup takes a group name, the key they've submitted, and Config's groups+keys. If the key & group received match a group within Config, return true (authentic). If no match is found, return false.

func DecodeHMAC

func DecodeHMAC(key string, encodedmessage []byte, verifyTimeout int64) (decodedMessage string, err error)

DecodeHMAC takes an hmac key and the ciphered message []byte they would like to decode. It matches the key with the group, then encodes the message using that key. It returns the decoded message as a string or an error. A message must be decoded within the timeout threshold (default is 30 seconds) of when it was encoded.

func EncodeHMAC

func EncodeHMAC(key string, rawmessage string, timestamp string) (encodedmessage []byte, err error)

EncodeHMAC takes * An hmac key * The raw string they would like to encode * The current timestamp (a payload with a timestamp of greater than or less than the timeout threshold (default is 30 seconds) will not be decrypted.) It encodes the message using the key. It returns an encrypted message []byte or an error. A message must be decoded within the timeout threshold (default of 30 seconds) of when it was encoded.

func GetKeyFromGroup

func GetKeyFromGroup(group string, groups *[]config.SecurityGroups) (key string, err error)

GetKeyFromGroup takes a group name and a pointer to array of groups. It returns the matching hmac key

Types

This section is empty.

Jump to

Keyboard shortcuts

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