crypto

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: BSD-3-Clause Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ExpectedKeyBytes is the number of bytes for the subscriber key.
	ExpectedKeyBytes = 16

	// ExpectedOpcBytes is the number of bytes for the operator variant algorithm configuration field.
	ExpectedOpcBytes = 16

	// ExpectedPlmnBytes is the number of bytes for the network identifier.
	ExpectedPlmnBytes = 3

	// ExpectedAmfBytes is the number of bytes for the authentication management field.
	ExpectedAmfBytes = 2

	// ExpectedOpBytes is the number of bytes for the operator variant configuration field.
	ExpectedOpBytes = 16

	// ExpectedAutsBytes is the number of bytes for the authentication token from the client key.
	ExpectedAutsBytes = 14

	// RandChallengeBytes is the number of bytes for the random challenge.
	RandChallengeBytes = 16

	// XresBytes is the number of bytes for the expected response.
	XresBytes = 8

	// AutnBytes is the number of bytes for the authentication token.
	AutnBytes = 16

	// KasmeBytes is the number of bytes for the base network authentication token.
	KasmeBytes = 32

	// ConfidentialityKeyBytes is the number of bytes for the confidentiality key.
	ConfidentialityKeyBytes = 16

	// IntegrityKeyBytes is the number of bytes for the integrity key.
	IntegrityKeyBytes = 16

	// AnonymityKeyBytes is the number of bytes for the anonymity key.
	AnonymityKeyBytes = 16
)

Variables

This section is empty.

Functions

func GenerateOpc

func GenerateOpc(key, op []byte) ([ExpectedOpcBytes]byte, error)

GenerateOpc returns the OP_c according to 3GPP 35.205 8.2 Inputs:

key: 128 bit subscriber key
op: 128 bit operator variant configuration field

Types

type EutranVector

type EutranVector struct {
	// Rand is a random challenge
	Rand [RandChallengeBytes]byte

	// Xres is the expected response
	Xres [XresBytes]byte

	// Autn is an authentication token
	Autn [AutnBytes]byte

	// Kasme is a base network authentication token
	Kasme [KasmeBytes]byte
}

EutranVector reprsents an E-UTRAN key vector.

type MilenageCipher

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

MilenageCipher implements the milenage algorithm (3GPP TS 35.205, .206, .207, .208)

func NewMilenageCipher

func NewMilenageCipher(amf []byte) (*MilenageCipher, error)

NewMilenageCipher instantiates the Milenage algo using crypto/rand for rng.

func NewMockMilenageCipher

func NewMockMilenageCipher(amf []byte, rand []byte) (*MilenageCipher, error)

NewMockMilenageCipher instantiates the Milenage algo using MockRNG for rng.

func (*MilenageCipher) GenerateEutranVector

func (milenage *MilenageCipher) GenerateEutranVector(key []byte, opc []byte, sqn uint64, plmn []byte) (*EutranVector, error)

GenerateEutranVector creates an E-UTRAN key vector. Inputs:

key: 128 bit subscriber key
opc: 128 bit operator variant algorithm configuration field
sqn: 48 bit sequence number
plmn: 24 bit network identifier
   Octet           Description
      1      MCC digit 2 | MCC digit 1
      2      MNC digit 3 | MCC digit 3
      3      MNC digit 2 | MNC digit 1

Outputs: An EutranVector or an error. The EutranVector is not nil if and only if err == nil.

func (*MilenageCipher) GenerateResync

func (milenage *MilenageCipher) GenerateResync(auts, key, opc, rand []byte) (uint64, [8]byte, error)

GenerateResync computes SQN_MS and MAC-S from AUTS for re-synchronization.

AUTS = SQN_MS ^ AK || f1*(SQN_MS || RAND || AMF*)

Inputs:

auts: 112 bit authentication token from client key
opc: 128 bit operator variant algorithm configuration field
key: 128 bit subscriber key
rand: 128 bit random challenge

Outputs: (sqnMs, macS) or an error

sqn_ms, 48 bit sequence number from client
mac_s, 64 bit resync authentication code

func (*MilenageCipher) GenerateSIPAuthVector

func (milenage *MilenageCipher) GenerateSIPAuthVector(key []byte, opc []byte, sqn uint64) (*SIPAuthVector, error)

GenerateSIPAuthVector creates a SIP auth vector. Inputs:

key: 128 bit subscriber key
opc: 128 bit operator variant algorithm configuration field
sqn: 48 bit sequence number

Outputs: A SIP auth vector or an error. The SIP auth vector is not nil if and only if err == nil.

func (*MilenageCipher) GenerateSIPAuthVectorWithRand

func (milenage *MilenageCipher) GenerateSIPAuthVectorWithRand(rand []byte, key []byte, opc []byte, sqn uint64) (*SIPAuthVector, error)

GenerateSIPAuthVectorWithRand creates a SIP auth vector using a specific random challenge value. Inputs:

rand: 128 bit random challenge
key:  128 bit subscriber key
opc:  128 bit operator variant algorithm configuration field
sqn:  48 bit sequence number

Outputs: A SIP auth vector or an error. The SIP auth vector is not nil if and only if err == nil.

type MockRNG

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

MockRNG yields a constant byte sequence instead of generating a new random sequence each time.

func (MockRNG) Read

func (rng MockRNG) Read(b []byte) (int, error)

type SIPAuthVector

type SIPAuthVector struct {
	// Rand is a random challenge
	Rand [RandChallengeBytes]byte

	// Xres is the expected response
	Xres [XresBytes]byte

	// Autn is an authentication token
	Autn [AutnBytes]byte

	// Confidentialitykey is used to ensure the confidentiality of messages
	ConfidentialityKey [ConfidentialityKeyBytes]byte

	// IntegrityKey is used to ensure the integrity of messages
	IntegrityKey [IntegrityKeyBytes]byte

	// AnonymityKey is used to ensure the anonymity of messages
	AnonymityKey [AnonymityKeyBytes]byte
}

SIPAuthVector represents the data encoded in a SIP auth data item.

Jump to

Keyboard shortcuts

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