Skip to content

Commit

Permalink
feat(udm): Maintain multiple previsioned home network keys (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
oommcclee committed Aug 9, 2021
1 parent bedd208 commit f87f31e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 36 deletions.
20 changes: 2 additions & 18 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/free5gc/openapi"
"github.com/free5gc/openapi/Nnrf_NFDiscovery"
"github.com/free5gc/openapi/models"
"github.com/free5gc/udm/factory"
"github.com/free5gc/util_3gpp/suci"
)

var udmContext UDMContext
Expand Down Expand Up @@ -44,7 +44,7 @@ type UDMContext struct {
GpsiSupiList models.IdentityData
SharedSubsDataMap map[string]models.SharedData // sharedDataIds as key
SubscriptionOfSharedDataChange sync.Map // subscriptionID as key
Keys *factory.Keys
SuciProfiles []suci.SuciProfile
EeSubscriptionIDGenerator *idgenerator.IDGenerator
}

Expand Down Expand Up @@ -85,22 +85,6 @@ type UdmNFContext struct {
SubscribeToNotifSharedDataChange *models.SdmSubscription // SubscriptionID as key
}

func (context *UDMContext) GetUdmProfileAHNPublicKey() string {
return context.Keys.UdmProfileAHNPublicKey
}

func (context *UDMContext) GetUdmProfileAHNPrivateKey() string {
return context.Keys.UdmProfileAHNPrivateKey
}

func (context *UDMContext) GetUdmProfileBHNPublicKey() string {
return context.Keys.UdmProfileBHNPublicKey
}

func (context *UDMContext) GetUdmProfileBHNPrivateKey() string {
return context.Keys.UdmProfileBHNPrivateKey
}

func (context *UDMContext) ManageSmData(smDatafromUDR []models.SessionManagementSubscriptionData, snssaiFromReq string,
dnnFromReq string) (mp map[string]models.SessionManagementSubscriptionData, ind string,
Dnns []models.DnnConfiguration, allDnns []map[string]models.DnnConfiguration) {
Expand Down
20 changes: 7 additions & 13 deletions factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ package factory

import (
"github.com/free5gc/logger_util"
"github.com/free5gc/util_3gpp/suci"
)

const (
UDM_EXPECTED_CONFIG_VERSION = "1.0.0"
UDM_EXPECTED_CONFIG_VERSION = "1.0.1"
)

type Config struct {
Expand All @@ -30,11 +31,11 @@ const (
)

type Configuration struct {
UdmName string `yaml:"udmName,omitempty"`
Sbi *Sbi `yaml:"sbi,omitempty"`
ServiceNameList []string `yaml:"serviceNameList,omitempty"`
NrfUri string `yaml:"nrfUri,omitempty"`
Keys *Keys `yaml:"keys,omitempty"`
UdmName string `yaml:"udmName,omitempty"`
Sbi *Sbi `yaml:"sbi,omitempty"`
ServiceNameList []string `yaml:"serviceNameList,omitempty"`
NrfUri string `yaml:"nrfUri,omitempty"`
SuciProfiles []suci.SuciProfile `yaml:"SuciProfile,omitempty"`
}

type Sbi struct {
Expand All @@ -52,13 +53,6 @@ type Tls struct {
Key string `yaml:"key,omitempty"`
}

type Keys struct {
UdmProfileAHNPrivateKey string `yaml:"udmProfileAHNPrivateKey,omitempty"`
UdmProfileAHNPublicKey string `yaml:"udmProfileAHNPublicKey,omitempty"`
UdmProfileBHNPrivateKey string `yaml:"udmProfileBHNPrivateKey,omitempty"`
UdmProfileBHNPublicKey string `yaml:"udmProfileBHNPublicKey,omitempty"`
}

func (c *Config) GetVersion() string {
if c.Info != nil && c.Info.Version != "" {
return c.Info.Version
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/free5gc/milenage v1.0.0
github.com/free5gc/openapi v1.0.0
github.com/free5gc/path_util v1.0.0
github.com/free5gc/util_3gpp v1.0.0
github.com/free5gc/util_3gpp v1.0.1
github.com/free5gc/version v1.0.0
github.com/gin-gonic/gin v1.6.3
github.com/google/uuid v1.1.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ github.com/free5gc/openapi v1.0.0 h1:DaGVt05b1pSDBOailKAlLj6hAk6vunN0Nhzvl/xcWCY
github.com/free5gc/openapi v1.0.0/go.mod h1:7OzxoWBj6KQgznMW2ZiUtZdCGY+t89v4wtgKLhluKgU=
github.com/free5gc/path_util v1.0.0 h1:vJPGTymaWtavz6fJ/7k6WKEYv5BQLAq/O04RP54sab0=
github.com/free5gc/path_util v1.0.0/go.mod h1:OpmcebEKrMPnH7Jg5lZ8y9ZWJNAjQ4l9FGWXUv58Mo0=
github.com/free5gc/util_3gpp v1.0.0 h1:yDuCFVlzLWKu6+vKBNG/PVAxjtrr8hPlJaTE/00hX8A=
github.com/free5gc/util_3gpp v1.0.0/go.mod h1:6uI6CB6SD/yWpalo17gc5eWUVFMAIKkWDiQpkOX3+c8=
github.com/free5gc/util_3gpp v1.0.1 h1:Ds93Ll9e3tKT5Wz50W5pAKgYpjHR+oxOeNKqSCWP+zI=
github.com/free5gc/util_3gpp v1.0.1/go.mod h1:Pk9xccNPnppwcND6MJqR7duZhjuGl6VlMeONARxiLv4=
github.com/free5gc/version v1.0.0 h1:Kn4uOhyHT1IAgerBgWRHag4xLMDXrRsqubLeMv5Nb/w=
github.com/free5gc/version v1.0.0/go.mod h1:wOTwzjk7sqeysX1b/Z4x+pWBHFuZOPtQj3h+IJXSpmQ=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
Expand Down
2 changes: 1 addition & 1 deletion producer/generate_auth_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest,

response = &models.AuthenticationInfoResult{}
rand.Seed(time.Now().UnixNano())
supi, err := suci.ToSupi(supiOrSuci, udm_context.UDM_Self().GetUdmProfileAHNPrivateKey())
supi, err := suci.ToSupi(supiOrSuci, udm_context.UDM_Self().SuciProfiles)
if err != nil {
problemDetails = &models.ProblemDetails{
Status: http.StatusForbidden,
Expand Down
2 changes: 1 addition & 1 deletion util/init_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func InitUDMContext(udmContext *context.UDMContext) {
udmContext.NrfUri = configuration.NrfUri
servingNameList := configuration.ServiceNameList

udmContext.Keys = configuration.Keys
udmContext.SuciProfiles = configuration.SuciProfiles

udmContext.InitNFService(servingNameList, config.Info.Version)
}

0 comments on commit f87f31e

Please sign in to comment.