MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / deriveLegacySKey

Function deriveLegacySKey

pkg/crypto/key_derivation.go:36–45  ·  view source on GitHub ↗

deriveLegacySKey derives a session key

(key types.AES128Key, t byte, jn types.JoinNonce, nid types.NetID, dn types.DevNonce)

Source from the content-addressed store, hash-verified

34
35// deriveLegacySKey derives a session key
36func deriveLegacySKey(key types.AES128Key, t byte, jn types.JoinNonce, nid types.NetID, dn types.DevNonce) (derived types.AES128Key) {
37 buf := make([]byte, 16)
38 buf[0] = t
39 copy(buf[1:4], reverse(jn[:]))
40 copy(buf[4:7], reverse(nid[:]))
41 copy(buf[7:9], reverse(dn[:]))
42 block, _ := aes.NewCipher(key[:])
43 block.Encrypt(derived[:], buf)
44 return
45}
46
47// DeriveFNwkSIntKey derives the LoRaWAN 1.1 Forwarding Network Session Integrity Key
48func DeriveFNwkSIntKey(nwkKey types.AES128Key, jn types.JoinNonce, joinEUI types.EUI64, dn types.DevNonce) types.AES128Key {

Callers 2

DeriveLegacyAppSKeyFunction · 0.85
DeriveLegacyNwkSKeyFunction · 0.85

Calls 2

reverseFunction · 0.85
EncryptMethod · 0.65

Tested by

no test coverage detected