crypt

package
v0.0.0-...-b9d6643 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

World of Warcraft cryptography modules. WoWCrypt for packet header encryption in the world server, and SRP6 for auth server authentication.

Index

Constants

View Source
const CryptRecvLength = 6

CryptRecvLength the length of the cryptable header.

View Source
const CryptSendLength = 4

CryptSendLength the length of the outbound cryptable header.

Variables

View Source
var ErrSizeNotMach = errors.New("digest size is not 20 bytes long")

ErrSizeNotMach the error when the digest size is not 20 bytes long.

Functions

func AuthSessionProof

func AuthSessionProof(accountName string, serverSeed, clientSeed []byte, sessionKey []byte) []byte

Generates verifier hash and client seed.

func CalculateServerProof

func CalculateServerProof(A, M, K *big.Int) *big.Int

CalculateServerProof will calculate a proof to send back to the client so they know we are a legit server.

func Hash

func Hash(parts ...[]byte) []byte

Hash calculates the SHA-1 hash of the provided byte slices.

It takes one or more byte slices as input and returns the calculated hash as a byte slice.

Types

type SRP6

type SRP6 struct {

	// Client private (a) and public (A) key
	A *big.Int

	// Server private (b) and public (B) key
	B *big.Int
	// contains filtered or unexported fields
}

The Secure Remote Password protocol (SRP) is an augmented password-authenticated key exchange (PAKE) protocol, specifically designed to work around existing patents.

func NewSRP6

func NewSRP6(g, k int64, N *big.Int) *SRP6

NewSRP6 initializes a new SRP6 instance.

func NewWoWSRP6

func NewWoWSRP6() *SRP6

NewWoWSRP6 initialize wow's SRP6 pre-filled variables.

func (*SRP6) CalculateClientSessionKey

func (s *SRP6) CalculateClientSessionKey(salt, B *big.Int, I, P string) (*big.Int, *big.Int)

func (*SRP6) CalculateServerSessionKey

func (s *SRP6) CalculateServerSessionKey(A, v, salt *big.Int, accountName string) (*big.Int, *big.Int)

CalculateServerSessionKey takes as input the client's proof and calculates the persistent session key. The function parameters are:

  • A: Client's public key
  • v: user's verifier
  • salt: user's generated salt
  • accountName: user's accout name or email

The two return values are:

K - Caclulated session key
M - Proof verification

func (*SRP6) G

func (s *SRP6) G() *big.Int

func (*SRP6) GValue

func (s *SRP6) GValue() int64

func (*SRP6) GenerateClientPubkey

func (s *SRP6) GenerateClientPubkey() *big.Int

GenerateClientPubkey generates a client public key for the SRP6 struct.

This function does not take any parameters. It returns a pointer to a big.Int.

func (*SRP6) GenerateServerPubKey

func (s *SRP6) GenerateServerPubKey(v *big.Int) *big.Int

GenerateServerPubKey generates a public ephemeral pair (B, b) given a user's verifier. The private key stored in this instance for later use.

func (*SRP6) GenerateVerifier

func (s *SRP6) GenerateVerifier(accountName, password string, salt *big.Int) *big.Int

GenerateVerifier will generate a hash of the account name, password and salt which can be used as the SRP verifier.

func (*SRP6) N

func (s *SRP6) N() *big.Int

N is the SRP Modulus; all operations are performed in base N.

func (*SRP6) RandomSalt

func (s *SRP6) RandomSalt() *big.Int

func (*SRP6) RandomScrambling

func (s *SRP6) RandomScrambling(A, B *big.Int) *big.Int

func (*SRP6) SetServerPrivateKey

func (s *SRP6) SetServerPrivateKey(val string)

SetServerPrivateKey sets server's private key. This is useful for testing purposes only. Use GenerateServerPubkey when it's possible! The val parameter should be a valid DECIMAL string.

type WowCrypt

type WowCrypt struct {
	// contains filtered or unexported fields
}

WowCrypt is a wrapper for rc4 ciphers. This crypter can be initialized with NewWowcrypt constructor.

func NewClientWoWCrypt

func NewClientWoWCrypt(key *big.Int, skip int) (*WowCrypt, error)

NewClientWoWCrypt initializes a client side crypter. The only difference from the server crypter is the encoder/decoder key setup.

func NewServerWowcrypt

func NewServerWowcrypt(key *big.Int, skip int) (*WowCrypt, error)

NewServerWowcrypt initializes the wow packet header crypter. The key should be the session key The session key should be 40 bytes long. which has been created on the auth session packet. The default skip for WOTLK client is 1024.

func (*WowCrypt) Decrypt

func (wc *WowCrypt) Decrypt(data []byte) []byte

Decrypt uses decoder to convert back the encrypted data.

func (*WowCrypt) Encrypt

func (wc *WowCrypt) Encrypt(data []byte) []byte

Encrypt uses the encoder to encode the given data.

func (*WowCrypt) Reset

func (wc *WowCrypt) Reset() error

This method will jumps back to the beginning of the stream again.

func (*WowCrypt) Skip

func (wc *WowCrypt) Skip(n int)

Skip skips n bytes in both encrypter and decrypter.

Jump to

Keyboard shortcuts

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