auth

package
v0.0.0-...-e0a30a8 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppID     = "AZEROTRUSTNETWORKACCESSTOANYONEL"
	EncOffset = 32 + 32 + 32 + 16
)
View Source
const (
	AuthIndexLen    = 32
	AuthRandomLen   = 16
	AuthIdLen       = 16
	AuthCheckValLen = 32
)

Variables

This section is empty.

Functions

func AppidCheckVal

func AppidCheckVal(id, random []byte) []byte

func BytesCombine

func BytesCombine(pBytes ...[]byte) []byte

func BytesXor

func BytesXor(a, b []byte) []byte

func GetSM2PubkeyFromCert

func GetSM2PubkeyFromCert(cert *sm2.Certificate) (*sm2.PublicKey, error)

func PKCS7Padding

func PKCS7Padding(origData []byte, blockSize int) []byte

func PKCS7UnPadding

func PKCS7UnPadding(origData []byte) []byte

func SM4DecryptCBC

func SM4DecryptCBC(key sm4.SM4Key, crypted []byte) []byte

func SM4EncryptCBC

func SM4EncryptCBC(key sm4.SM4Key, packet []byte) []byte

func UserIdCheckVal

func UserIdCheckVal(uid, iv, random []byte) []byte

Types

type AuthCheckVal

type AuthCheckVal [AuthCheckValLen]byte

func (*AuthCheckVal) SetBytes

func (s *AuthCheckVal) SetBytes(data []byte)

type AuthData

type AuthData struct {
	ClientIndex AuthIndex
	AppIdChk    AuthCheckVal
	UsrIdChk    AuthCheckVal
	Random      AuthRandom
}

type AuthID

type AuthID [AuthIdLen]byte

type AuthIndex

type AuthIndex [AuthIndexLen]byte

type AuthRandom

type AuthRandom [AuthRandomLen]byte

type AuthTables

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

func (*AuthTables) Add

func (this *AuthTables) Add(ID AuthID)

func (*AuthTables) Del

func (this *AuthTables) Del(ID AuthID)

func (*AuthTables) Exist

func (this *AuthTables) Exist(ID AuthID) bool

type Authorize

type Authorize struct {
	SM4Key sm4.SM4Key
	// contains filtered or unexported fields
}

func NewAuthorize

func NewAuthorize() *Authorize

func (Authorize) CheckId

func (this Authorize) CheckId(data *AuthData, pid AuthID) bool

func (Authorize) CheckVal

func (this Authorize) CheckVal(data *AuthData) bool

func (Authorize) DecPacket

func (this Authorize) DecPacket(packet []byte) ([]byte, int)

func (Authorize) EncPacket

func (this Authorize) EncPacket(data []byte) []byte

func (Authorize) GenerateAuthData

func (this Authorize) GenerateAuthData(id AuthID, pubkey []byte) *AuthData

Jump to

Keyboard shortcuts

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