ComputeLegacyJoinAcceptMIC computes the Message Integrity Code for a join-accept message - The payload contains MHDR | JoinNonce/AppNonce | NetID | DevAddr | DLSettings | RxDelay | (CFList | CFListType) - In LoRaWAN 1.0, the AppKey is used - In LoRaWAN 1.1 with OptNeg=0, the NwkKey is used
(key types.AES128Key, payload []byte)
| 131 | // - In LoRaWAN 1.0, the AppKey is used |
| 132 | // - In LoRaWAN 1.1 with OptNeg=0, the NwkKey is used |
| 133 | func ComputeLegacyJoinAcceptMIC(key types.AES128Key, payload []byte) ([4]byte, error) { |
| 134 | if n := len(payload); n != 13 && n != 29 { |
| 135 | return [4]byte{}, errInvalidJoinAcceptPayloadSize.WithAttributes("size", len(payload)) |
| 136 | } |
| 137 | hash, err := cmac.New(key[:]) |
| 138 | if err != nil { |
| 139 | return [4]byte{}, err |
| 140 | } |
| 141 | _, err = hash.Write(payload) |
| 142 | if err != nil { |
| 143 | return [4]byte{}, err |
| 144 | } |
| 145 | var mic [4]byte |
| 146 | copy(mic[:], hash.Sum([]byte{})) |
| 147 | return mic, nil |
| 148 | } |
| 149 | |
| 150 | // ComputeJoinAcceptMIC computes the Message Integrity Code for a join-accept message |
| 151 | // - The payload contains MHDR | JoinNonce | NetID | DevAddr | DLSettings | RxDelay | (CFList | CFListType) |