Documentation
¶
Index ¶
- Constants
- func AddStandardAnswerAVPS(answer *diam.Message, sessionID datatype.UTF8String, ...)
- func BoolToInt(b bool) int
- func ConstructFailureAnswer(msg *diam.Message, sessionID datatype.UTF8String, ...) *diam.Message
- func ConstructSuccessAnswer(msg *diam.Message, sessionID datatype.UTF8String, ...) *diam.Message
- func ConvertAuthErrorToFailureMessage(err error, msg *diam.Message, sessionID datatype.UTF8String, ...) *diam.Message
- func GenerateLteAuthVector(milenage *crypto.MilenageCipher, subscriber *protos.SubscriberData, ...) (*crypto.EutranVector, uint64, error)
- func GenerateLteAuthVectors(numVectors uint32, milenage *crypto.MilenageCipher, ...) ([]*crypto.EutranVector, uint64, error)
- func GetConfiguredSubscribers() ([]*protos.SubscriberData, error)
- func GetHSSConfig() (*mconfig.HSSConfig, error)
- func GetNextLteAuthSqnAfterResync(state *protos.SubscriberState, sqn uint64) (uint64, error)
- func GetOrGenerateOpc(lte *protos.LTESubscription, lteAuthOp []byte) ([]byte, error)
- func IsAllZero(bytes []byte) bool
- func NewAIA(srv *HomeSubscriberServer, msg *diam.Message) (*diam.Message, error)
- func NewMAA(srv *HomeSubscriberServer, msg *diam.Message) (*diam.Message, error)
- func NewSAA(srv *HomeSubscriberServer, msg *diam.Message) (*diam.Message, error)
- func NewULA(srv *HomeSubscriberServer, msg *diam.Message) (*diam.Message, error)
- func ResyncLteAuthSeq(subscriber *protos.SubscriberData, resyncInfo, lteAuthOp []byte) (uint64, error)
- func SeqToSqn(seq, index uint64) uint64
- func SplitSqn(sqn uint64) (uint64, uint64)
- func ValidateAIR(msg *diam.Message) error
- func ValidateLteSubscription(lte *protos.LTESubscription) error
- func ValidateMAR(msg *diam.Message) error
- func ValidateSAR(msg *diam.Message) error
- func ValidateULR(msg *diam.Message) error
- type AuthDataUnavailableError
- type AuthRejectedError
- type HomeSubscriberServer
- func (srv *HomeSubscriberServer) AddSubscriber(ctx context.Context, req *lteprotos.SubscriberData) (*protos.Void, error)
- func (srv *HomeSubscriberServer) DeleteSubscriber(ctx context.Context, req *lteprotos.SubscriberID) (*protos.Void, error)
- func (srv *HomeSubscriberServer) DeregisterSubscriber(ctx context.Context, req *lteprotos.SubscriberID) (*protos.Void, error)
- func (srv *HomeSubscriberServer) GenerateSIPAuthVector(subscriber *lteprotos.SubscriberData) (*crypto.SIPAuthVector, uint64, error)
- func (srv *HomeSubscriberServer) GenerateSIPAuthVectors(subscriber *lteprotos.SubscriberData, numVectors uint32) ([]*crypto.SIPAuthVector, uint64, error)
- func (srv *HomeSubscriberServer) GetSubscriberData(ctx context.Context, req *lteprotos.SubscriberID) (*lteprotos.SubscriberData, error)
- func (srv *HomeSubscriberServer) NewSuccessfulAIA(msg *diam.Message, sessionID datatype.UTF8String, ...) *diam.Message
- func (srv *HomeSubscriberServer) NewSuccessfulMAA(msg *diam.Message, sessionID datatype.UTF8String, userName datatype.UTF8String, ...) *diam.Message
- func (srv *HomeSubscriberServer) NewSuccessfulULA(msg *diam.Message, sessionID datatype.UTF8String, ...) *diam.Message
- func (srv *HomeSubscriberServer) Start(started chan string) error
- func (srv *HomeSubscriberServer) TerminateRegistration(sub *protos.SubscriberData) error
- func (srv *HomeSubscriberServer) UpdateSubscriber(ctx context.Context, req *lteprotos.SubscriberData) (*protos.Void, error)
Constants ¶
const PermanentTermination = 0
Permanently terminate the non-3gpp subscription
Variables ¶
This section is empty.
Functions ¶
func AddStandardAnswerAVPS ¶
func AddStandardAnswerAVPS(answer *diam.Message, sessionID datatype.UTF8String, serverCfg *mconfig.DiamServerConfig, resultCode uint32)
AddStandardAnswerAVPS adds the SessionID, ExperimentalResult, OriginHost, OriginRealm, and OriginStateID AVPs to a message.
func ConstructFailureAnswer ¶
func ConstructFailureAnswer(msg *diam.Message, sessionID datatype.UTF8String, serverCfg *mconfig.DiamServerConfig, resultCode uint32) *diam.Message
ConstructFailureAnswer creates an answer for the message with an embedded Experimental-Result AVP. This answer informs the peer that the request has failed. See 3GPP TS 29.272 section 7.4.3 (permanent errors) and section 7.4.4 (transient errors).
func ConstructSuccessAnswer ¶
func ConstructSuccessAnswer(msg *diam.Message, sessionID datatype.UTF8String, serverCfg *mconfig.DiamServerConfig, authApplicationID uint32) *diam.Message
ConstructSuccessAnswer returns a message response with a success result code and with the server config AVPs already added.
func ConvertAuthErrorToFailureMessage ¶
func ConvertAuthErrorToFailureMessage(err error, msg *diam.Message, sessionID datatype.UTF8String, serverCfg *mconfig.DiamServerConfig) *diam.Message
ConvertAuthErrorToFailureMessage creates a corresponding diameter failure message for an auth error.
func GenerateLteAuthVector ¶
func GenerateLteAuthVector(milenage *crypto.MilenageCipher, subscriber *protos.SubscriberData, plmn, lteAuthOp []byte, authSqnInd uint64) (*crypto.EutranVector, uint64, error)
GenerateLteAuthVector returns the lte auth vector for the subscriber. Inputs:
milenage: The cipher to use to generate the vector subscriber: The subscriber data for the subscriber we want to generate auth vectors for plmn: 24 bit network identifier authSqnInd: the IND of the current vector being generated
Returns: A E-UTRAN vector and the next value to set the subscriber's LteAuthNextSeq to (or an error).
func GenerateLteAuthVectors ¶
func GenerateLteAuthVectors(numVectors uint32, milenage *crypto.MilenageCipher, subscriber *protos.SubscriberData, plmn, lteAuthOp []byte, authSqnInd uint64) ([]*crypto.EutranVector, uint64, error)
GenerateLteAuthVectors generates at most `numVectors` lte auth vectors. Inputs:
numVectors: The maximum number of vectors to generate milenage: The cipher to use to generate the vector subscriber: The subscriber data for the subscriber we want to generate auth vectors for plmn: 24 bit network identifier authSqnInd: the IND of the current vector being generated
Returns: The E-UTRAN vectors and the next value to set the subscriber's LteAuthNextSeq to (or an error).
func GetConfiguredSubscribers ¶
func GetConfiguredSubscribers() ([]*protos.SubscriberData, error)
GetConfiguredSubscribers returns a slice of subscribers configured in hss.yml
func GetHSSConfig ¶
GetHSSConfig returns the server config for an HSS based on the input flags
func GetNextLteAuthSqnAfterResync ¶
func GetNextLteAuthSqnAfterResync(state *protos.SubscriberState, sqn uint64) (uint64, error)
GetNextLteAuthSqnAfterResync returns the value of the next sequence number after sqn or an error if a resync should not occur. See 3GPP TS 33.102 Appendix C.3.
func GetOrGenerateOpc ¶
func GetOrGenerateOpc(lte *protos.LTESubscription, lteAuthOp []byte) ([]byte, error)
GetOrGenerateOpc returns lte.AuthOpc and generates if it isn't stored in the proto
func NewAIA ¶
NewAIA outputs a authentication information answer (AIA) to reply to an authentication information request (AIR) message.
func NewMAA ¶
NewMAA outputs a multimedia authentication answer (MAA) to reply to a multimedia authentication request (MAR) message.
func NewSAA ¶
NewSAA outputs a server assignment answer (SAA) to reply to a server assignment request (SAR) message. See 3GPP TS 29.273 section 8.1.2.2.2.2.
func NewULA ¶
NewULA outputs a update location answer (ULA) to reply to an update location request (ULR) message.
func ResyncLteAuthSeq ¶
func ResyncLteAuthSeq(subscriber *protos.SubscriberData, resyncInfo, lteAuthOp []byte) (uint64, error)
ResyncLteAuthSeq validates a re-synchronization request and computes the SEQ from the AUTS sent by U-SIM. The next value of lteAuthNextSeq (or an error) is returned. See 3GPP TS 33.102 section 6.3.5.
func SeqToSqn ¶
SeqToSqn computes the 48 bit SQN given a seq given the formula defined in 3GPP TS 33.102 Annex C.3.2. The length of IND is 5 bits. SQN = SEQ || IND Inputs:
seq: the sequence number index: the index of the current vector being generated
Output: The 48 bit SQN
func SplitSqn ¶
SplitSqn computes the SEQ and IND given a 48 bit SQN using the formula defined in 3GPP TS 33.102 Annex C.3.2. The length of IND is 5 bits. SQN = SEQ || IND Inputs:
seq: the 48 bit SQN
Outputs: SEQ and IND
func ValidateAIR ¶
ValidateAIR returns an error if the message is missing any mandatory AVPs. Mandatory AVPs are specified in 3GPP TS 29.272 Table 5.2.3.1.1/1
func ValidateLteSubscription ¶
func ValidateLteSubscription(lte *protos.LTESubscription) error
ValidateLteSubscription returns an error if and only if the lte proto is not configured up to use the milenage authentication algorithm.
func ValidateMAR ¶
ValidateMAR returns an error if the message is missing any mandatory AVPs. Mandatory AVPs are specified in 3GPP TS 29.273 Table 8.1.2.1.1/1.
func ValidateSAR ¶
ValidateSAR returns an error if the message is missing any mandatory AVPs. Mandatory AVPs are specified in 3GPP TS 29.273 Table 8.1.2.2.2.1/1.
func ValidateULR ¶
ValidateULR returns an error if the message is missing any mandatory AVPs. Mandatory AVPs are specified in 3GPP TS 29.272 Table 5.2.1.1.1/1
Types ¶
type AuthDataUnavailableError ¶
type AuthDataUnavailableError struct {
// contains filtered or unexported fields
}
AuthDataUnavailableError indicates that an unexpectedly transient authentication failure occurs. See 3GPP TS 29.272 section 7.4.4.1.
func NewAuthDataUnavailableError ¶
func NewAuthDataUnavailableError(msg string) AuthDataUnavailableError
NewAuthDataUnavailableError creates an AuthDataUnavailableError.
func (AuthDataUnavailableError) Error ¶
func (err AuthDataUnavailableError) Error() string
type AuthRejectedError ¶
type AuthRejectedError struct {
// contains filtered or unexported fields
}
AuthRejectedError indicates that the HSS cannot return any authentication vectors due to unallowed attachment of the UE. See 3GPP TS 29.272 section 5.2.3.1.3.
func NewAuthRejectedError ¶
func NewAuthRejectedError(msg string) AuthRejectedError
NewAuthRejectedError creates an AuthRejectedError.
func (AuthRejectedError) Error ¶
func (err AuthRejectedError) Error() string
type HomeSubscriberServer ¶
type HomeSubscriberServer struct { Config *mconfig.HSSConfig Milenage *crypto.MilenageCipher // authSqnInd is an index used in the array scheme described by 3GPP TS 33.102 Appendix C.1.2 and C.2.2. // SQN consists of two parts (SQN = SEQ||IND). AuthSqnInd uint64 // contains filtered or unexported fields }
HomeSubscriberServer tracks all the accounts needed for authenticating users.
func NewHomeSubscriberServer ¶
func NewHomeSubscriberServer(store storage.SubscriberStore, config *mconfig.HSSConfig) (*HomeSubscriberServer, error)
NewHomeSubscriberServer initializes a HomeSubscriberServer with an empty accounts map. Output: a new HomeSubscriberServer
func (*HomeSubscriberServer) AddSubscriber ¶
func (srv *HomeSubscriberServer) AddSubscriber(ctx context.Context, req *lteprotos.SubscriberData) (*protos.Void, error)
AddSubscriber tries to add this subscriber to the server. This function returns an AlreadyExists error if the subscriber has already been added. Input: The subscriber data which will be added.
func (*HomeSubscriberServer) DeleteSubscriber ¶
func (srv *HomeSubscriberServer) DeleteSubscriber(ctx context.Context, req *lteprotos.SubscriberID) (*protos.Void, error)
DeleteSubscriber deletes a subscriber by their Id. If the subscriber is not found, then this call is ignored. Input: The id of the subscriber to be deleted.
func (*HomeSubscriberServer) DeregisterSubscriber ¶
func (srv *HomeSubscriberServer) DeregisterSubscriber(ctx context.Context, req *lteprotos.SubscriberID) (*protos.Void, error)
DeRegisterSubscriber de-registers a subscriber by their Id. If the subscriber is not found, an error is returned instead. Input: The id of the subscriber to be deregistered.
func (*HomeSubscriberServer) GenerateSIPAuthVector ¶
func (srv *HomeSubscriberServer) GenerateSIPAuthVector(subscriber *lteprotos.SubscriberData) (*crypto.SIPAuthVector, uint64, error)
GenerateSIPAuthVector returns the SIP auth vector and the next value of lteAuthNextSeq for the subscriber (or an error).
func (*HomeSubscriberServer) GenerateSIPAuthVectors ¶
func (srv *HomeSubscriberServer) GenerateSIPAuthVectors(subscriber *lteprotos.SubscriberData, numVectors uint32) ([]*crypto.SIPAuthVector, uint64, error)
GenerateSIPAuthVectors generates `numVectors` SIP auth vectors for the subscriber. The vectors and the next value of lteAuthNextSeq are returned (or an error).
func (*HomeSubscriberServer) GetSubscriberData ¶
func (srv *HomeSubscriberServer) GetSubscriberData(ctx context.Context, req *lteprotos.SubscriberID) (*lteprotos.SubscriberData, error)
GetSubscriberData looks up a subscriber by their Id. If the subscriber cannot be found, an error is returned instead. Input: The id of the subscriber to be looked up. Output: The data of the corresponding subscriber.
func (*HomeSubscriberServer) NewSuccessfulAIA ¶
func (srv *HomeSubscriberServer) NewSuccessfulAIA(msg *diam.Message, sessionID datatype.UTF8String, vectors []*crypto.EutranVector) *diam.Message
NewSuccessfulAIA outputs a successful authentication information answer (AIA) to reply to an authentication information request (AIR) message. It populates AIA with all of the mandatory fields and adds the authentication vectors.
func (*HomeSubscriberServer) NewSuccessfulMAA ¶
func (srv *HomeSubscriberServer) NewSuccessfulMAA(msg *diam.Message, sessionID datatype.UTF8String, userName datatype.UTF8String, vectors []*crypto.SIPAuthVector) *diam.Message
NewSuccessfulMAA outputs a successful multimedia authentication answer (MAA) to reply to an multimedia authentication request (MAR) message. It populates the MAA with all of the mandatory fields and adds the authentication vectors. See 3GPP TS 29.273 table 8.1.2.1.1/5.
func (*HomeSubscriberServer) NewSuccessfulULA ¶
func (srv *HomeSubscriberServer) NewSuccessfulULA(msg *diam.Message, sessionID datatype.UTF8String, profile *mconfig.HSSConfig_SubscriptionProfile) *diam.Message
NewSuccessfulULA outputs a successful update location answer (ULA) to reply to an update location request (ULR) message. It populates the ULA with all of the mandatory fields and adds the subscriber profile information.
func (*HomeSubscriberServer) Start ¶
func (srv *HomeSubscriberServer) Start(started chan string) error
Start begins the server and blocks, listening to the network Input: a channel to signal when the server is started & return the local server address string Output: error if the server could not be started
func (*HomeSubscriberServer) TerminateRegistration ¶
func (srv *HomeSubscriberServer) TerminateRegistration(sub *protos.SubscriberData) error
func (*HomeSubscriberServer) UpdateSubscriber ¶
func (srv *HomeSubscriberServer) UpdateSubscriber(ctx context.Context, req *lteprotos.SubscriberData) (*protos.Void, error)
UpdateSubscriber changes the data stored for an existing subscriber. If the subscriber cannot be found, an error is returned instead. Input: The new subscriber data to store