Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support LoRaWAN 1.2.0 default cipher suite #7248

Closed
wants to merge 15 commits into from

Conversation

halimi
Copy link
Contributor

@halimi halimi commented Aug 19, 2024

Summary

References: https://github.com/TheThingsIndustries/lorawan-stack/issues/4313

LoRaWAN 1.2.0 standard supports different cipher suites. Each cipher suite defines a set of encryption and MIC calculation functions. There is a new MIC calculation for downlink, called DOWNLINK_MIC_A_SCHEME. There are also two new MAC commands DevMobilityInd/DevMobilityResp and NegotiationInd/NegotiationConf. Besides that there is a new field in ResetInd/ResetConf and RekeyInd/RekeyConf to support the cipher suites.

Changes

  • Support JoinRequest for LoRaWAN 1.2 devices
  • Support RekeyInd / RekeyConf MAC command with cipher ID
  • Support ResetInd / ResetConf MAC command with cipher ID
  • TODO Implement DOWNLINK_MIC_A_SCHEME
  • TODO Support different cipher suites
  • TODO Implement NegotiationInd and NegotiationConf MAC command
  • TODO Implement DevMobilityInd and DevMobilityResp MAC command

Testing

Steps
  1. Support JoinRequest for LoRaWAN 1.2 devices
  • Pre-requisite: Create an application and gateway
  • Create a lorawan v1.2 capable end device
  • Simulate the JoinRequest
Results
  1. Support JoinRequest for LoRaWAN 1.2 devices
  • Create a lorawan v1.2 capable end device
APP_ID="my-new-application"
DEVICE_ID="dev12"
FREQUENCY_PLAN="EU_863_870"
DEV_EUI="0004A30B001C0530"
APP_EUI="800000000000000C"
APP_KEY="752BAEC23EAE7964AF27C325F4C23C9A"
NWK_KEY="01020304050607080102030405060708"

go run ./cmd/ttn-lw-cli end-devices create $APP_ID $DEVICE_ID --dev-eui $DEV_EUI --app-eui $APP_EUI --frequency-plan-id $FREQUENCY_PLAN --root-keys.app-key.key $APP_KEY --root-keys.nwk-key.key $NWK_KEY --lorawan-version 1.2.0 --lorawan-phy-version 1.1.0-b

{
  "ids": {
    "device_id": "dev12",
    "application_ids": {
      "application_id": "my-new-application"
    },
    "dev_eui": "0004A30B001C0530",
    "join_eui": "800000000000000C"
  },
  "created_at": "2024-09-02T14:56:21.679623Z",
  "updated_at": "2024-09-02T14:56:21.706295Z",
  "attributes": {},
  "network_server_address": "localhost",
  "application_server_address": "localhost",
  "join_server_address": "localhost",
  "lorawan_version": "MAC_V1_2_0",
  "lorawan_phy_version": "PHY_V1_1_REV_B",
  "frequency_plan_id": "EU_863_870",
  "supports_join": true,
  "root_keys": {
    "app_key": {
      "key": "752BAEC23EAE7964AF27C325F4C23C9A"
    },
    "nwk_key": {
      "key": "01020304050607080102030405060708"
    }
  }
}
  • Simulate the JoinRequest
go run ./cmd/ttn-lw-cli simulate gateway-join-request --lorawan-version MAC_V1_2_0  --gateway-id gw1 --join_eui 800000000000000C --dev_eui 0004A30B001C0530 --dev-nonce 0001 --nwk-key 01020304050607080102030405060708 --app-key 752BAEC23EAE7964AF27C325F4C23C9A  --band-id EU_863_870 --frequency 868100000

{
  "raw_payload": "IHjp12PITp+0mOaOSleZAy0plsmxzap33L9PVJfrJbm2",
  "payload": {
    "m_hdr": {
      "m_type": "JOIN_ACCEPT"
    },
    "mic": "0DM6XA==",
    "join_accept_payload": {
      "encrypted": "eOnXY8hOn7SY5o5KV5kDLSmWybHNqnfcv09Ul+slubY=",
      "join_nonce": "000001",
      "net_id": "000000",
      "dev_addr": "006CFC18",
      "dl_settings": {
        "opt_neg": true
      },
      "rx_delay": 5,
      "cf_list": {
        "freq": [
          8671000,
          8673000,
          8675000,
          8677000,
          8679000
        ]
      }
    }
  },
  "scheduled": {
    "data_rate": {
      "lora": {
        "bandwidth": 125000,
        "spreading_factor": 12,
        "coding_rate": "4/5"
      }
    },
    "frequency": "868100000",
    "timestamp": 2909779178,
    "downlink": {
      "tx_power": 16.15,
      "invert_polarization": true
    },
    "concentrator_timestamp": "2909779178000"
  },
  "correlation_ids": [
    "gs:down:token:1",
    "gs:uplink:01J6SNZ1HK54B66ZTSTZABT2TH",
    "ns:downlink:01J6SNZ3C80130PTS28T6W6YTW",
    "ns:transmission:01J6SNZ3C88JJH9HNWMTYSXNFK",
    "rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01J6SNZ1HKDPKREBD9XYC0VY2K",
    "rpc:/ttn.lorawan.v3.GtwGs/LinkGateway:01J6SNZ1GXMSJEH8Z9SM1B07WK",
    "rpc:/ttn.lorawan.v3.NsGs/ScheduleDownlink:01J6SNZ3C91V5TZNNBQWN80DPV"
  ]
}
Regressions

...

Notes for Reviewers

...

Checklist

  • Scope: The referenced issue is addressed, there are no unrelated changes.
  • Compatibility: The changes are backwards compatible with existing API, storage, configuration and CLI, according to the compatibility commitments in README.md for the chosen target branch.
  • Documentation: Relevant documentation is added or updated.
  • Testing: The steps/process to test this feature are clearly explained including testing for regressions.
  • Infrastructure: If infrastructural changes (e.g., new RPC, configuration) are needed, a separate issue is created in the infrastructural repositories.
  • Changelog: Significant features, behavior changes, deprecations and fixes are added to CHANGELOG.md.
  • Commits: Commit messages follow guidelines in CONTRIBUTING.md, there are no fixup commits left.

@github-actions github-actions bot added the security This is important for security label Aug 19, 2024
@halimi halimi self-assigned this Aug 19, 2024
@halimi halimi added this to the v3.32.1 milestone Aug 19, 2024
@halimi halimi force-pushed the feature/lorawan-1.2-encryption branch from f371a4f to 37786cf Compare August 19, 2024 11:10
@halimi halimi force-pushed the feature/lorawan-1.2-encryption branch from a4491f9 to 298f078 Compare August 20, 2024 12:44
@halimi halimi force-pushed the feature/lorawan-1.2-encryption branch from b722404 to 3498d67 Compare August 21, 2024 15:43
@halimi halimi changed the title Support LoRaWAN 1.2.0 DOWNLINK_MIC_A_SCHEME Support LoRaWAN 1.2.0 default cipher suite Aug 21, 2024
@github-actions github-actions bot added the c/network server This is related to the Network Server label Aug 22, 2024
@github-actions github-actions bot added the c/join server This is related to the Join Server label Aug 27, 2024
@halimi halimi force-pushed the feature/lorawan-1.2-encryption branch from 62d74b5 to 664683f Compare August 28, 2024 09:26
@halimi halimi force-pushed the feature/lorawan-1.2-encryption branch from 4cf915c to d5ab632 Compare August 28, 2024 13:06
@github-actions github-actions bot added the ui/web This is related to a web interface label Sep 4, 2024
@github-actions github-actions bot added the c/gateway server This is related to the Gateway Server label Sep 12, 2024
@halimi halimi force-pushed the feature/lorawan-1.2-encryption branch from 53fe44b to 11483ce Compare September 12, 2024 14:26
@halimi halimi force-pushed the feature/lorawan-1.2-encryption branch from 6db97d6 to c1f4e47 Compare September 23, 2024 09:43
@KrishnaIyer KrishnaIyer removed this from the v3.32.1 milestone Oct 7, 2024
@KrishnaIyer
Copy link
Member

@halimi, as discussed, let's close this PR but leave the branch.

@halimi
Copy link
Contributor Author

halimi commented Oct 7, 2024

I'm closing this issue now because of the LoRaWAN standard version 1.2.0 is not finalized yet and we are expecting some major change will come. So for now, we put on hold the implementation and later we will continue with the new version of the standard.

@halimi halimi closed this Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/gateway server This is related to the Gateway Server c/join server This is related to the Join Server c/network server This is related to the Network Server security This is important for security ui/web This is related to a web interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants