Skip to content

Commit

Permalink
feat(udm): Maintain multiple previsioned home network keys
Browse files Browse the repository at this point in the history
  • Loading branch information
oommcclee committed Aug 3, 2021
1 parent 525cc11 commit 93e2222
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
18 changes: 3 additions & 15 deletions context/context.go
Original file line number Diff line number Diff line change
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
Keys *[]factory.Key
EeSubscriptionIDGenerator *idgenerator.IDGenerator
}

Expand Down Expand Up @@ -85,20 +85,8 @@ 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) GetUdmHNPrivateKeybyHNPublicKeyID(index int) string {
return (*context.Keys)[index-1].PrivateKey
}

func (context *UDMContext) ManageSmData(smDatafromUDR []models.SessionManagementSubscriptionData, snssaiFromReq string,
Expand Down
12 changes: 6 additions & 6 deletions factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Configuration struct {
Sbi *Sbi `yaml:"sbi,omitempty"`
ServiceNameList []string `yaml:"serviceNameList,omitempty"`
NrfUri string `yaml:"nrfUri,omitempty"`
Keys *Keys `yaml:"keys,omitempty"`
Keys *[]Key `yaml:"keys,omitempty"`
}

type Sbi struct {
Expand All @@ -52,11 +52,11 @@ 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"`
type Key struct {
HomeNetworkPublicKeyIdentifier int `yaml:"HomeNetworkPublicKeyIdentifier,omitempty"`
ProtectionScheme string `yaml:"ProtectionScheme,omitempty"`
PrivateKey string `yaml:"PrivateKey,omitempty"`
PublicKey string `yaml:"PublicKey,omitempty"`
}

func (c *Config) GetVersion() string {
Expand Down
3 changes: 1 addition & 2 deletions producer/generate_auth_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/free5gc/openapi"
"github.com/free5gc/openapi/Nudr_DataRepository"
"github.com/free5gc/openapi/models"
udm_context "github.com/free5gc/udm/context"
"github.com/free5gc/udm/logger"
"github.com/free5gc/udm/util"
"github.com/free5gc/util_3gpp/suci"
Expand Down Expand Up @@ -159,7 +158,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)
if err != nil {
problemDetails = &models.ProblemDetails{
Status: http.StatusForbidden,
Expand Down

0 comments on commit 93e2222

Please sign in to comment.