tools

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Various helper functions, that are used by RADIUS Client & Server to encode/decode information inside RADIUS packet They are also available to crate users to prepare data before it is packed into RADIUS packet

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToIPv4String

func BytesToIPv4String(ipv4 []uint8) (string, error)

BytesToIPv4String converts IPv4 bytes into IPv4 string

func BytesToIPv6String

func BytesToIPv6String(ipv6 []uint8) (string, bool)

BytesToIPv6String converts IPv6 bytes into IPv6 string Returns value & bool => need to check bool, if true then successful, otherwise not

func BytesToInteger

func BytesToInteger(integer []uint8) (uint32, bool)

BytesToInteger converts integer bytes into u32

func BytesToInteger64

func BytesToInteger64(integer []uint8) (uint64, bool)

BytesToInteger64 converts integer bytes into u64

func BytesToTimestamp

func BytesToTimestamp(timestamp []uint8) (uint32, bool)

BytesToTimestamp converts timestamp bytes into int64

Golang has timestamps as int64, however RADIIUS protocol has timestamp('time') as uint32 therefore we need to apply a bit of logic to link these 2 together

func DecryptData

func DecryptData(data, authenticator, secret *[]uint8) []uint8

DecryptData decrypts data since RADIUS packet is sent in plain text

Should be used to decrypt value of **User-Password** attribute (but could also be used to decrypt any data)

func EncryptData

func EncryptData(data, authenticator, secret *[]uint8) []uint8

EncryptData encrypts data since RADIUS packet is sent in plain text

Should be used to encrypt value of **User-Password** attribute (but could also be used to encrypt any data)

func IPv4StringToBytes

func IPv4StringToBytes(ipv4 string) ([]uint8, error)

IPv4StringToBytes converts IPv4 Address string into vector of bytes

Should be used for any Attribute of type **ipaddr**, **ipv4addr** & **ipv4prefix** to ensure value is encoded correctly Returns value & error, so need to check if any errors occured before using the value

func IPv6StringToBytes

func IPv6StringToBytes(ipv6 string) ([]uint8, error)

IPv6StringToBytes converts IPv6 Address string into vector of bytes

Should be used for any Attribute of type **ipv6addr** or **ipv6prefix** to ensure value is encoded correctly Returns value & error, so need to check if any errors occured before using the value

func Integer64ToBytes

func Integer64ToBytes(integer uint64) []uint8

Integer64ToBytes converts u64 into vector of bytes

Should be used for any Attribute of type **integer** to ensure value is encoded correctly

func IntegerToBytes

func IntegerToBytes(integer uint32) []uint8

IntegerToBytes converts u32 into vector of bytes

Should be used for any Attribute of type **integer** to ensure value is encoded correctly

func SaltDecryptData

func SaltDecryptData(data, authenticator, secret *[]uint8) ([]uint8, error)

SaltDecryptData decrypts data with salt since RADIUS packet is sent in plain text

Should be used for RADIUS Tunnel-Password Attribute

func SaltEncryptData

func SaltEncryptData(data, authenticator, salt, secret *[]uint8) []uint8

SaltEncryptData encrypts data with salt since RADIUS packet is sent in plain text

Should be used for RADIUS Tunnel-Password Attribute

func TimestampToBytes

func TimestampToBytes(timestamp int64) ([]uint8, error)

TimestampToBytes converts timestamp (int64) into vector of bytes

Should be used for any Attribute of type **date** to ensure value is encoded correctly

Golang has timestamps as int64, however RADIIUS protocol expects timestamp('time') as uint32 therefore we need to apply a bit of logic to link these 2 together Returns value & error, so need to check if any errors occured before using the value

Types

This section is empty.

Jump to

Keyboard shortcuts

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