Documentation
¶
Overview ¶
Package ipcrypt implements IP address encryption and obfuscation methods. It provides three encryption modes:
- ipcrypt-deterministic: A deterministic mode where the same input always produces the same output
- ipcrypt-nd: A non-deterministic mode that uses an 8-byte tweak
- ipcrypt-ndx: An extended non-deterministic mode that uses a 32-byte key and 16-byte tweak
For non-deterministic modes, passing nil as the tweak parameter will automatically generate a random tweak.
Index ¶
- Constants
- Variables
- func DecryptIP(key []byte, encrypted net.IP) (net.IP, error)
- func DecryptIPNonDeterministic(ciphertext []byte, key []byte) (string, error)
- func DecryptIPNonDeterministicX(ciphertext []byte, key []byte) (string, error)
- func DecryptIPPfx(encryptedIP net.IP, key []byte) (net.IP, error)
- func EncryptIP(key []byte, ip net.IP) (net.IP, error)
- func EncryptIPNonDeterministic(ip string, key []byte, tweak []byte) ([]byte, error)
- func EncryptIPNonDeterministicX(ip string, key []byte, tweak []byte) ([]byte, error)
- func EncryptIPPfx(ip net.IP, key []byte) (net.IP, error)
- func KiasuBCDecrypt(key, tweak, block []byte) ([]byte, error)
- func KiasuBCEncrypt(key, tweak, block []byte) ([]byte, error)
Constants ¶
const ( KeySizeDeterministic = 16 // Size in bytes of the key for ipcrypt-deterministic mode KeySizeND = 16 // Size in bytes of the key for ipcrypt-nd mode KeySizeNDX = 32 // Size in bytes of the key for ipcrypt-ndx mode )
Key sizes for different encryption modes
const ( TweakSize = 8 // Size in bytes of the tweak for ipcrypt-nd mode TweakSizeX = 16 // Size in bytes of the tweak for ipcrypt-ndx mode )
Tweak sizes for different encryption modes
Variables ¶
var ( ErrInvalidKeySize = errors.New("invalid key size") ErrInvalidIP = errors.New("invalid IP address") ErrInvalidTweak = errors.New("invalid tweak size") )
Error definitions for the package
Functions ¶
func DecryptIP ¶
DecryptIP decrypts an IP address that was encrypted using ipcrypt-deterministic mode. The key must be exactly KeySizeDeterministic bytes long. Returns the decrypted IP address as a net.IP.
func DecryptIPNonDeterministic ¶
DecryptIPNonDeterministic decrypts an IP address that was encrypted using ipcrypt-nd mode. The key must be exactly KeySizeND bytes long. Returns the decrypted IP address as a string.
func DecryptIPNonDeterministicX ¶
DecryptIPNonDeterministicX decrypts an IP address that was encrypted using ipcrypt-ndx mode. The key must be exactly KeySizeNDX bytes long. Returns the decrypted IP address as a string.
func DecryptIPPfx ¶ added in v0.1.1
DecryptIPPfx decrypts an IP address that was encrypted using ipcrypt-pfx mode. The key must be exactly 32 bytes long (split into two AES-128 keys). Returns the decrypted IP address.
func EncryptIP ¶
EncryptIP encrypts an IP address using ipcrypt-deterministic mode. The key must be exactly KeySizeDeterministic bytes long. Returns the encrypted IP address as a net.IP.
func EncryptIPNonDeterministic ¶
EncryptIPNonDeterministic encrypts an IP address using ipcrypt-nd mode. The key must be exactly KeySizeND bytes long. If tweak is nil, a random tweak will be generated. Returns a byte slice containing the tweak concatenated with the encrypted IP.
func EncryptIPNonDeterministicX ¶
EncryptIPNonDeterministicX encrypts an IP address using ipcrypt-ndx mode. The key must be exactly KeySizeNDX bytes long. If tweak is nil, a random tweak will be generated. Returns a byte slice containing the tweak concatenated with the encrypted IP.
func EncryptIPPfx ¶ added in v0.1.1
EncryptIPPfx encrypts an IP address using ipcrypt-pfx mode. The key must be exactly 32 bytes long (split into two AES-128 keys). Returns the encrypted IP address maintaining the original format (IPv4 or IPv6).
func KiasuBCDecrypt ¶
KiasuBCDecrypt decrypts a 16-byte block using KIASU-BC with the given key and tweak.
func KiasuBCEncrypt ¶
KiasuBCEncrypt encrypts a 16-byte block using KIASU-BC with the given key and tweak.
Types ¶
This section is empty.