mirror of
https://github.com/yibaiba/hideck.git
synced 2026-12-06 00:01:20 +00:00
fix(vowifi): complete AIS EAP-AKA challenge response
This commit is contained in:
1 parent
f1615d532b
commit
b9fbdbebac
6 files changed
+62
-18
No files matched your search
+7
-14
@@ -15,18 +15,11 @@ import (
|
||||
func (s *Session) resolveATCheckcodeValue(
|
||||
mode string,
|
||||
eapType uint8,
|
||||
hasCheckcode bool,
|
||||
serverValue []byte,
|
||||
shouldEcho bool,
|
||||
) []byte {
|
||||
if !hasCheckcode {
|
||||
return nil
|
||||
}
|
||||
) ([]byte, bool) {
|
||||
switch normalizeAKAChallengeMode(mode) {
|
||||
case "checkcode":
|
||||
if shouldEcho {
|
||||
return append([]byte(nil), serverValue...)
|
||||
}
|
||||
return append([]byte(nil), serverValue...), true
|
||||
case "recompute":
|
||||
hashType := "sha1"
|
||||
if eapType == eapaka.TypeAKAPrime {
|
||||
@@ -34,10 +27,10 @@ func (s *Session) resolveATCheckcodeValue(
|
||||
}
|
||||
checkcode := s.calcAKACheckcodeWithPending(hashType, nil)
|
||||
if len(checkcode) > 0 {
|
||||
return append([]byte{0, 0}, checkcode...)
|
||||
return checkcode, true
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (s *Session) appendAKAChallengeMetaAttrs(
|
||||
@@ -62,9 +55,9 @@ func (s *Session) appendAKAChallengeMetaAttrs(
|
||||
if includeCheckcode && hasCheckcode {
|
||||
value, err := checkcode.CheckcodeValue()
|
||||
if err == nil {
|
||||
resolved := s.resolveATCheckcodeValue(modeForCheckcode(mode), request.Type, true, value, len(value) > 0)
|
||||
if len(resolved) >= 2 {
|
||||
filtered = append(filtered, eapaka.CheckcodeAttribute(resolved[2:]))
|
||||
resolved, include := s.resolveATCheckcodeValue(modeForCheckcode(mode), request.Type, value)
|
||||
if include {
|
||||
filtered = append(filtered, eapaka.CheckcodeAttribute(resolved))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,55 @@ func TestNormalizeAKAChallengeModeMatchesLegacyAliases(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMinimalAKAChallengePreservesEmptyCheckcode(t *testing.T) {
|
||||
session := NewSession(&Config{AKAChallengeMode: "minimal"})
|
||||
request := eapaka.Packet{
|
||||
Type: eapaka.TypeAKA,
|
||||
Attributes: []eapaka.Attribute{eapaka.CheckcodeAttribute(nil)},
|
||||
}
|
||||
|
||||
attrs := session.appendAKAChallengeMetaAttrs(nil, request)
|
||||
checkcode, ok := eapaka.FindAttribute(attrs, eapaka.AttributeCheckcode)
|
||||
if !ok {
|
||||
t.Fatal("empty AT_CHECKCODE was omitted")
|
||||
}
|
||||
value, err := checkcode.CheckcodeValue()
|
||||
if err != nil {
|
||||
t.Fatalf("parse AT_CHECKCODE: %v", err)
|
||||
}
|
||||
if len(value) != 0 {
|
||||
t.Fatalf("AT_CHECKCODE = %x, want empty value", value)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckcodeModePreservesCompleteServerValue(t *testing.T) {
|
||||
want := bytes.Repeat([]byte{0x5a}, 20)
|
||||
session := NewSession(&Config{AKAChallengeMode: "checkcode"})
|
||||
request := eapaka.Packet{
|
||||
Type: eapaka.TypeAKA,
|
||||
Attributes: []eapaka.Attribute{
|
||||
eapaka.CheckcodeAttribute(want),
|
||||
eapaka.ResultIndAttribute(),
|
||||
},
|
||||
}
|
||||
|
||||
attrs := session.appendAKAChallengeMetaAttrs(nil, request)
|
||||
checkcode, ok := eapaka.FindAttribute(attrs, eapaka.AttributeCheckcode)
|
||||
if !ok {
|
||||
t.Fatal("AT_CHECKCODE was omitted")
|
||||
}
|
||||
value, err := checkcode.CheckcodeValue()
|
||||
if err != nil {
|
||||
t.Fatalf("parse AT_CHECKCODE: %v", err)
|
||||
}
|
||||
if !bytes.Equal(value, want) {
|
||||
t.Fatalf("AT_CHECKCODE = %x, want %x", value, want)
|
||||
}
|
||||
if _, ok := eapaka.FindAttribute(attrs, eapaka.AttributeResultInd); !ok {
|
||||
t.Fatal("AT_RESULT_IND was omitted in checkcode mode")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLegacyIdentitySelectionAndKeyDerivationFallback(t *testing.T) {
|
||||
session := NewSession(&Config{IMSI: "234102356143376", FastReauthID: "fast@example"})
|
||||
if got := session.currentIKEIdentity(); got != "fast@example" {
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
func TestOriginalCarrierPresetAssetsRemainExact(t *testing.T) {
|
||||
wantHashes := map[string]string{
|
||||
"2degrees_nz_53024.yaml": "40ba4fc4b21aed123cb5d2c3634a3a4a0d7d7a33046dd2e356e8950e6250c471",
|
||||
"ais_th_52001.yaml": "2cd640d7fd2983d203f13c4f4a1687bd64ea4961a3325022b1888ee5088060ff",
|
||||
"ais_th_52003.yaml": "60abafbf24b623df3e6a1e1c30476b414a75f67d9c05ea5b159670314d864749",
|
||||
"ais_th_52001.yaml": "f02b536317933c00c1960bfcceaf1b3f2ec8e22e1106917854231953832ccaa0",
|
||||
"ais_th_52003.yaml": "7b7c444a9c641d19c9ea184997c27c24eacc52d6b31db729b448fe9e1f50d0fd",
|
||||
"att_310280.yaml": "7337399037af7fbe67874b83f8f0c95ff0a1c588ec49ee41a404cf33e04fd054",
|
||||
"att_310410.yaml": "06c030e8bd636271f9a23400cd4a622187cb38792fdc01b5422a4d719ff59b95",
|
||||
"cmhk_45412.yaml": "b38938fedd7069a0f46959724c133e7c4ebab15369346d7623f901bcb4c603d5",
|
||||
|
||||
@@ -2,6 +2,7 @@ mcc: "520"
|
||||
mnc: "01"
|
||||
id: ais_th_52001
|
||||
device_model: rmx3366
|
||||
aka_challenge_mode: checkcode
|
||||
dpd_interval_seconds: 120
|
||||
ike_proposals:
|
||||
- aes256-sha256-prfsha256-modp2048
|
||||
|
||||
@@ -2,6 +2,7 @@ mcc: "520"
|
||||
mnc: "03"
|
||||
id: ais_th_52003
|
||||
device_model: rmx3366
|
||||
aka_challenge_mode: checkcode
|
||||
dpd_interval_seconds: 120
|
||||
ike_proposals:
|
||||
- aes256-sha256-prfsha256-modp2048
|
||||
|
||||
+2
-2
@@ -53,8 +53,8 @@ var originalCarrierStartupExpectations = []carrierStartupExpectation{
|
||||
{name: "Globe PH", mcc: "515", mnc: "02", normalizedMNC: "002", imsi: "515020000000001", presetID: "globe_ph_51502", epdg: "epdg.epc.mnc002.mcc515.pub.3gppnetwork.org", epdgSource: "standard", espFirst: "aes256-sha256", templateID: "globe_ph_51502", akaMode: "minimal", dpdSeconds: 120},
|
||||
{name: "Smart PH", mcc: "515", mnc: "03", normalizedMNC: "003", imsi: "515030000000001", presetID: "smart_ph_51503", epdg: "epdg.epc.mnc003.mcc515.pub.3gppnetwork.org", epdgSource: "standard", espFirst: "aes256-sha256", templateID: "smart_ph_51503", akaMode: "minimal", dpdSeconds: 120},
|
||||
{name: "DITO PH", mcc: "515", mnc: "66", normalizedMNC: "066", imsi: "515660000000001", presetID: "dito_51566", epdg: "epdg.epc.mnc066.mcc515.pub.3gppnetwork.org", epdgSource: "standard", espFirst: "aes256-sha256", templateID: "dito_51566", akaMode: "minimal", dpdSeconds: 120},
|
||||
{name: "AIS TH 01", mcc: "520", mnc: "01", normalizedMNC: "001", imsi: "520010000000001", presetID: "ais_th_52001", epdg: "epdg.epc.mnc001.mcc520.pub.3gppnetwork.org", epdgSource: "standard", espFirst: "aes256-sha256", templateID: "ais_th_52001", akaMode: "minimal", dpdSeconds: 120},
|
||||
{name: "AIS TH 03", mcc: "520", mnc: "03", normalizedMNC: "003", imsi: "520030000000001", presetID: "ais_th_52003", epdg: "epdg.epc.mnc003.mcc520.pub.3gppnetwork.org", epdgSource: "standard", espFirst: "aes256-sha256", templateID: "ais_th_52003", akaMode: "minimal", dpdSeconds: 120},
|
||||
{name: "AIS TH 01", mcc: "520", mnc: "01", normalizedMNC: "001", imsi: "520010000000001", presetID: "ais_th_52001", epdg: "epdg.epc.mnc001.mcc520.pub.3gppnetwork.org", epdgSource: "standard", espFirst: "aes256-sha256", templateID: "ais_th_52001", akaMode: "checkcode", dpdSeconds: 120},
|
||||
{name: "AIS TH 03", mcc: "520", mnc: "03", normalizedMNC: "003", imsi: "520030000000001", presetID: "ais_th_52003", epdg: "epdg.epc.mnc003.mcc520.pub.3gppnetwork.org", epdgSource: "standard", espFirst: "aes256-sha256", templateID: "ais_th_52003", akaMode: "checkcode", dpdSeconds: 120},
|
||||
{name: "MTN NG", mcc: "621", mnc: "30", normalizedMNC: "030", imsi: "621300000000001", presetID: "mtn_ng_62130", epdg: "epdg.epc.mnc030.mcc621.pub.3gppnetwork.org", epdgSource: "standard", espFirst: "aes256-sha256", templateID: "mtn_ng_62130", akaMode: "minimal", dpdSeconds: 120},
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user