Documentation
¶
Index ¶
- func ConvertPublicKeyToSPKI(publicKey *rsa.PublicKey) ([]byte, error)
- func Decrypt(block cipher.Block, iv, ciphertext []byte) []byte
- func Encrypt(block cipher.Block, iv, plaintext []byte) []byte
- func ExtractPublicKeyFromPEM(publicKeyPEM string) ([]byte, error)
- func MinecraftSHA1(s string) string
- func NewDecryptStream(block cipher.Block, iv []byte) cipher.Stream
- func NewEncryptStream(block cipher.Block, iv []byte) cipher.Stream
- func ParseRSAPrivateKey(privateKeyPEM string) (*rsa.PrivateKey, error)
- func ParseRSAPublicKey(publicKeyPEM string) (*rsa.PublicKey, error)
- type Encryption
- func (e *Encryption) Decrypt(data []byte) []byte
- func (e *Encryption) DecryptWithPrivateKey(privateKey *rsa.PrivateKey, data []byte) ([]byte, error)
- func (e *Encryption) EnableEncryption() error
- func (e *Encryption) Encrypt(data []byte) []byte
- func (e *Encryption) EncryptWithPublicKey(publicKeyBytes []byte, data []byte) ([]byte, error)
- func (e *Encryption) GenerateSharedSecret() ([]byte, error)
- func (e *Encryption) GetSharedSecret() []byte
- func (e *Encryption) IsEnabled() bool
- func (e *Encryption) SetSharedSecret(secret []byte)
- type MinecraftSHA1Builder
- type Stream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertPublicKeyToSPKI ¶
ConvertPublicKeyToSPKI converts an RSA public key to SPKI DER format
func Decrypt ¶
Decrypt decrypts the ciphertext using CFB8 mode with the given block cipher and IV. It returns the plaintext which will be the same length as the ciphertext.
func Encrypt ¶
Encrypt encrypts the plaintext using CFB8 mode with the given block cipher and IV. It returns the ciphertext which will be the same length as the plaintext.
func ExtractPublicKeyFromPEM ¶
ExtractPublicKeyFromPEM extracts the raw public key bytes from a PEM string
func MinecraftSHA1 ¶
MinecraftSHA1 creates the SHA1 hash digest of the given Minecraft username, used for auth on server side. Original implementation: https://gist.github.com/toqueteos/5372776
func NewDecryptStream ¶
NewDecryptStream creates a cipher.Stream for decryption using CFB8.
func NewEncryptStream ¶
NewEncryptStream creates a cipher.Stream for encryption using CFB8.
func ParseRSAPrivateKey ¶
func ParseRSAPrivateKey(privateKeyPEM string) (*rsa.PrivateKey, error)
ParseRSAPrivateKey parses an RSA private key from PEM format Supports both PKCS#8 and PKCS#1 formats
Types ¶
type Encryption ¶
type Encryption struct {
// contains filtered or unexported fields
}
func NewEncryption ¶
func NewEncryption() *Encryption
func (*Encryption) Decrypt ¶
func (e *Encryption) Decrypt(data []byte) []byte
func (*Encryption) DecryptWithPrivateKey ¶
func (e *Encryption) DecryptWithPrivateKey(privateKey *rsa.PrivateKey, data []byte) ([]byte, error)
func (*Encryption) EnableEncryption ¶
func (e *Encryption) EnableEncryption() error
func (*Encryption) Encrypt ¶
func (e *Encryption) Encrypt(data []byte) []byte
func (*Encryption) EncryptWithPublicKey ¶
func (e *Encryption) EncryptWithPublicKey(publicKeyBytes []byte, data []byte) ([]byte, error)
func (*Encryption) GenerateSharedSecret ¶
func (e *Encryption) GenerateSharedSecret() ([]byte, error)
func (*Encryption) GetSharedSecret ¶
func (e *Encryption) GetSharedSecret() []byte
func (*Encryption) IsEnabled ¶
func (e *Encryption) IsEnabled() bool
func (*Encryption) SetSharedSecret ¶
func (e *Encryption) SetSharedSecret(secret []byte)
type MinecraftSHA1Builder ¶
MinecraftSHA1Builder provides a way to build Minecraft-style SHA1 hashes
func NewMinecraftSHA1 ¶
func NewMinecraftSHA1() *MinecraftSHA1Builder
NewMinecraftSHA1 creates a new Minecraft SHA1 builder
func (*MinecraftSHA1Builder) HexDigest ¶
func (m *MinecraftSHA1Builder) HexDigest() string
HexDigest returns the Minecraft-style hex digest