(t *testing.T)
| 27 | ) |
| 28 | |
| 29 | func TestJoinAcceptEncryption(t *testing.T) { |
| 30 | a := assertions.New(t) |
| 31 | |
| 32 | _, err := EncryptJoinAccept(types.AES128Key{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, nil) |
| 33 | a.So(err, should.NotBeNil) |
| 34 | _, err = DecryptJoinAccept(types.AES128Key{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, nil) |
| 35 | a.So(err, should.NotBeNil) |
| 36 | |
| 37 | for i, tc := range []struct { |
| 38 | Key types.AES128Key |
| 39 | Decrypted, Encrypted []byte |
| 40 | }{ |
| 41 | { |
| 42 | Key: types.AES128Key{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, |
| 43 | Decrypted: []byte{ |
| 44 | /* JoinNonce */ |
| 45 | 0x03, 0x02, 0x01, |
| 46 | /* NetID */ |
| 47 | 0x03, 0x02, 0x01, |
| 48 | /* DevAddr */ |
| 49 | 0x04, 0x03, 0x02, 0x01, |
| 50 | /* DLSettings */ |
| 51 | 0x00, |
| 52 | /* RxDelay */ |
| 53 | 0x01, |
| 54 | /* MIC */ |
| 55 | 0x32, 0xf5, 0x4a, 0xb3, |
| 56 | }, |
| 57 | Encrypted: []byte{0xc9, 0xfb, 0xb2, 0x59, 0xe1, 0x16, 0x49, 0x09, 0x6a, 0x56, 0x8a, 0x9e, 0x3b, 0x71, 0x17, 0xc3}, |
| 58 | }, |
| 59 | } { |
| 60 | t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { |
| 61 | a := assertions.New(t) |
| 62 | |
| 63 | key := deepcopy.Copy(tc.Key).(types.AES128Key) |
| 64 | dec := slices.Clone(tc.Decrypted) |
| 65 | enc, err := EncryptJoinAccept(key, dec) |
| 66 | a.So(err, should.BeNil) |
| 67 | a.So(dec, should.Resemble, tc.Decrypted) |
| 68 | a.So(enc, should.Resemble, tc.Encrypted) |
| 69 | a.So(key, should.Resemble, tc.Key) |
| 70 | |
| 71 | key = deepcopy.Copy(tc.Key).(types.AES128Key) |
| 72 | enc = slices.Clone(tc.Encrypted) |
| 73 | dec, err = DecryptJoinAccept(tc.Key, tc.Encrypted) |
| 74 | a.So(err, should.BeNil) |
| 75 | a.So(dec, should.Resemble, tc.Decrypted) |
| 76 | a.So(enc, should.Resemble, tc.Encrypted) |
| 77 | a.So(key, should.Resemble, tc.Key) |
| 78 | }) |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | func TestComputeJoinRequestMIC(t *testing.T) { |
| 83 | a := assertions.New(t) |
nothing calls this directly
no test coverage detected