rc4
import "github.com/TheManticoreProject/Manticore/crypto/rc4"
Index
type KeySizeError
KeySizeError is returned when the provided key is not of the correct size.
type KeySizeError int
func (KeySizeError) Error
func (k KeySizeError) Error() string
Error implements the error interface. Parameters:
- k: The KeySizeError value representing the invalid key size
Returns:
- string: A formatted error message indicating the invalid key size
type RC4
RC4 represents an RC4 cipher instance.
type RC4 struct {
// Key is the key used to initialize the cipher.
Key []byte
// contains filtered or unexported fields
}
func NewRC4
func NewRC4() (*RC4, error)
NewRC4 creates and returns a new RC4 cipher. The key is empty, so the cipher is not initialized. Parameters:
- None
Returns:
- *RC4: A pointer to a new RC4 cipher instance
- error: An error if the cipher could not be created
func NewRC4WithKey
func NewRC4WithKey(key []byte) (*RC4, error)
NewRC4WithKey creates and returns a new RC4 cipher with the given key. The key must be between 1 and 256 bytes in length. Parameters:
- key: The byte slice containing the key for the RC4 cipher
Returns:
- *RC4: A pointer to a new RC4 cipher instance initialized with the key
- error: An error if the key size is invalid
func (*RC4) Reset
func (c *RC4) Reset()
Reset zeros the key data and resets the cipher to its initial state. Parameters:
- c: The RC4 cipher instance to reset
Returns:
- None
func (*RC4) XORKeyStream
func (c *RC4) XORKeyStream(dst, src []byte)
XORKeyStream applies the RC4 cipher to the byte slice. It encrypts or decrypts the bytes in src and writes the result to dst. Src and dst may be the same slice but otherwise should not overlap. Parameters:
- dst: The destination byte slice where the result will be written
- src: The source byte slice containing the data to be encrypted/decrypted
Returns:
- None
Panics:
- If dst is smaller than src
- If src and dst overlap but are not identical slices