mschapv2

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Copyright © 2024 Keytos alan@keytos.io

Define MS-CHAPv2 cryptographic operations

Copyright © 2024 Keytos alan@keytos.io

Define MS-CHAPv2 packet data for EAP

Only hold "Data" section (anything after first `Type`)

Copyright © 2024 Keytos alan@keytos.io

Define MS-CHAPv2 packets

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthenticatorResponse

func AuthenticatorResponse(pwhh, ntResponse, challengeHash []byte) []byte

func ChallengeHash

func ChallengeHash(peerc, authc []byte, uname string) []byte

func NTPasswordHash

func NTPasswordHash(pw []byte) []byte

func SessionKeys

func SessionKeys(pwhh, ntResponse []byte) (recvKey, sendKey []byte)

func Utf16Bytes

func Utf16Bytes(s string) []byte

func WriteNTResponse

func WriteNTResponse(dst, pwh, chall []byte)

Types

type Challenge

type Challenge struct {
	OpCode     OpCode
	Identifier uint8
	Length     uint16
	ValueSize  uint8
	Challenge  [16]byte
	Name       []byte
}

Challenge packet

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     Code      |   Identifier  |            Length             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     Type      |   OpCode      |  MS-CHAPv2-ID |  MS-Length...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   MS-Length   |  Value-Size   |  Challenge...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             Challenge...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             Name...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func CreateChallengeFromBuffer added in v0.2.0

func CreateChallengeFromBuffer(data []byte) (*Challenge, error)

type OpCode

type OpCode uint8
const (
	OpCodeChallenge OpCode = iota + 1
	OpCodeResponse
	OpCodeSuccess
	OpCodeFailure
)

type Request

type Request struct {
	OpCode     OpCode
	Identifier uint8
	Length     uint16
	Message    string
}

Success/Failure Request

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     Code      |   Identifier  |            Length             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     Type      |   OpCode      |  MS-CHAPv2-ID |  MS-Length...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   MS-Length   |                    Message...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func ReadRequest

func ReadRequest(data []byte) (*Request, error)

type Response

type Response struct {
	OpCode        OpCode
	Identifier    uint8
	Length        uint16
	ValueSize     uint8
	PeerChallenge [16]byte
	Reserved      [8]byte
	NTResponse    [24]byte
	Flag          uint8
	Name          []byte
}

Response packet

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     Code      |   Identifier  |            Length             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     Type      |   OpCode      |  MS-CHAPv2-ID |  MS-Length...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   MS-Length   |  Value-Size   |    Response...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             Response...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             Name...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func CreateEmptyResponse

func CreateEmptyResponse(c *Challenge, uname string) *Response

func (Response) ToBinary

func (r Response) ToBinary() []byte

Jump to

Keyboard shortcuts

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