Matter fix CASE with resumption (#18371)

This commit is contained in:
s-hadinger 2023-04-09 15:39:08 +02:00 committed by GitHub
parent 52060259ce
commit a8242d1ec5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 869 additions and 851 deletions

View File

@ -316,7 +316,7 @@ class Matter_Commisioning_Context
import string
# sanity checks
if msg.opcode != 0x30 || msg.local_session_id != 0 || msg.protocol_id != 0
tasmota.log("MTR: invalid Sigma1 message", 2)
# tasmota.log("MTR: invalid Sigma1 message", 2)
tasmota.log("MTR: StatusReport(General Code: FAILURE, ProtocolId: SECURE_CHANNEL, ProtocolCode: INVALID_PARAMETER)", 2)
var raw = self.send_status_report(msg, 0x01, 0x0000, 0x0002, false)
return false
@ -426,12 +426,12 @@ class Matter_Commisioning_Context
return true
else
sigma1.resumptionID = nil
is_resumption = false
# fall through normal sigma1 (non-resumption)
end
end
if sigma1.resumptionID == nil || sigma1.initiatorResumeMIC == nil
if !is_resumption
tasmota.log("MTR: fabric="+matter.inspect(session._fabric), 4)
tasmota.log("MTR: no_private_key="+session._fabric.no_private_key.tohex(), 4)

View File

@ -208,7 +208,7 @@ class Matter_Plugin_Root : Matter_Plugin
elif cluster == 0x0028 # ========== Basic Information Cluster cluster 11.1 p.565 ==========
if attribute == 0x0000 # ---------- DataModelRevision / CommissioningWindowStatus ----------
return TLV.create_TLV(TLV.U2, 0)
return TLV.create_TLV(TLV.U2, 1)
elif attribute == 0x0001 # ---------- VendorName / string ----------
return TLV.create_TLV(TLV.UTF1, "Tasmota")
elif attribute == 0x0002 # ---------- VendorID / vendor-id ----------

View File

@ -840,12 +840,15 @@ class Matter_Session_Store
#############################################################
# find session by resumption id
def find_session_by_resumption_id(resumption_id)
import string
if !resumption_id return nil end
var i = 0
var sessions = self.sessions
while i < size(sessions)
var session = sessions[i]
tasmota.log(string.format("MTR: session.resumption_id=%s vs %s", str(session.resumption_id), str(resumption_id)))
if session.resumption_id == resumption_id && session.shared_secret != nil
tasmota.log(string.format("MTR: session.shared_secret=%s", str(session.shared_secret)))
session.update()
return session
end

View File

@ -661,7 +661,7 @@ be_local_closure(Matter_Plugin_Root_read_attribute, /* name */
0x781E0005, // 0224 JMPF R7 #022B
0x8C1C0906, // 0225 GETMET R7 R4 K6
0x8824090C, // 0226 GETMBR R9 R4 K12
0x58280005, // 0227 LDCONST R10 K5
0x58280009, // 0227 LDCONST R10 K9
0x7C1C0600, // 0228 CALL R7 3
0x80040E00, // 0229 RET 1 R7
0x7002009B, // 022A JMP #02C7

View File

@ -4083,7 +4083,7 @@ be_local_closure(Matter_Session_Store_add_fabric, /* name */
********************************************************************/
be_local_closure(Matter_Session_Store_find_session_by_resumption_id, /* name */
be_nested_proto(
7, /* nstack */
14, /* nstack */
2, /* argc */
2, /* varg */
0, /* has upvals */
@ -4091,42 +4091,70 @@ be_local_closure(Matter_Session_Store_find_session_by_resumption_id, /* name *
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 6]) { /* constants */
/* K0 */ be_const_int(0),
/* K1 */ be_nested_str_weak(sessions),
/* K2 */ be_nested_str_weak(resumption_id),
/* K3 */ be_nested_str_weak(shared_secret),
/* K4 */ be_nested_str_weak(update),
/* K5 */ be_const_int(1),
( &(const bvalue[12]) { /* constants */
/* K0 */ be_nested_str_weak(string),
/* K1 */ be_const_int(0),
/* K2 */ be_nested_str_weak(sessions),
/* K3 */ be_nested_str_weak(tasmota),
/* K4 */ be_nested_str_weak(log),
/* K5 */ be_nested_str_weak(format),
/* K6 */ be_nested_str_weak(MTR_X3A_X20session_X2Eresumption_id_X3D_X25s_X20vs_X20_X25s),
/* K7 */ be_nested_str_weak(resumption_id),
/* K8 */ be_nested_str_weak(shared_secret),
/* K9 */ be_nested_str_weak(MTR_X3A_X20session_X2Eshared_secret_X3D_X25s),
/* K10 */ be_nested_str_weak(update),
/* K11 */ be_const_int(1),
}),
be_str_weak(find_session_by_resumption_id),
&be_const_str_solidified,
( &(const binstruction[25]) { /* code */
0x5C080200, // 0000 MOVE R2 R1
0x740A0001, // 0001 JMPT R2 #0004
0x4C080000, // 0002 LDNIL R2
0x80040400, // 0003 RET 1 R2
0x58080000, // 0004 LDCONST R2 K0
0x880C0101, // 0005 GETMBR R3 R0 K1
0x6010000C, // 0006 GETGBL R4 G12
0x5C140600, // 0007 MOVE R5 R3
0x7C100200, // 0008 CALL R4 1
0x14100404, // 0009 LT R4 R2 R4
0x7812000C, // 000A JMPF R4 #0018
0x94100602, // 000B GETIDX R4 R3 R2
0x88140902, // 000C GETMBR R5 R4 K2
0x1C140A01, // 000D EQ R5 R5 R1
0x78160006, // 000E JMPF R5 #0016
0x88140903, // 000F GETMBR R5 R4 K3
0x4C180000, // 0010 LDNIL R6
0x20140A06, // 0011 NE R5 R5 R6
0x78160002, // 0012 JMPF R5 #0016
0x8C140904, // 0013 GETMET R5 R4 K4
0x7C140200, // 0014 CALL R5 1
0x80040800, // 0015 RET 1 R4
0x00080505, // 0016 ADD R2 R2 K5
0x7001FFED, // 0017 JMP #0006
0x80000000, // 0018 RET 0
( &(const binstruction[47]) { /* code */
0xA40A0000, // 0000 IMPORT R2 K0
0x5C0C0200, // 0001 MOVE R3 R1
0x740E0001, // 0002 JMPT R3 #0005
0x4C0C0000, // 0003 LDNIL R3
0x80040600, // 0004 RET 1 R3
0x580C0001, // 0005 LDCONST R3 K1
0x88100102, // 0006 GETMBR R4 R0 K2
0x6014000C, // 0007 GETGBL R5 G12
0x5C180800, // 0008 MOVE R6 R4
0x7C140200, // 0009 CALL R5 1
0x14140605, // 000A LT R5 R3 R5
0x78160021, // 000B JMPF R5 #002E
0x94140803, // 000C GETIDX R5 R4 R3
0xB81A0600, // 000D GETNGBL R6 K3
0x8C180D04, // 000E GETMET R6 R6 K4
0x8C200505, // 000F GETMET R8 R2 K5
0x58280006, // 0010 LDCONST R10 K6
0x602C0008, // 0011 GETGBL R11 G8
0x88300B07, // 0012 GETMBR R12 R5 K7
0x7C2C0200, // 0013 CALL R11 1
0x60300008, // 0014 GETGBL R12 G8
0x5C340200, // 0015 MOVE R13 R1
0x7C300200, // 0016 CALL R12 1
0x7C200800, // 0017 CALL R8 4
0x7C180400, // 0018 CALL R6 2
0x88180B07, // 0019 GETMBR R6 R5 K7
0x1C180C01, // 001A EQ R6 R6 R1
0x781A000F, // 001B JMPF R6 #002C
0x88180B08, // 001C GETMBR R6 R5 K8
0x4C1C0000, // 001D LDNIL R7
0x20180C07, // 001E NE R6 R6 R7
0x781A000B, // 001F JMPF R6 #002C
0xB81A0600, // 0020 GETNGBL R6 K3
0x8C180D04, // 0021 GETMET R6 R6 K4
0x8C200505, // 0022 GETMET R8 R2 K5
0x58280009, // 0023 LDCONST R10 K9
0x602C0008, // 0024 GETGBL R11 G8
0x88300B08, // 0025 GETMBR R12 R5 K8
0x7C2C0200, // 0026 CALL R11 1
0x7C200600, // 0027 CALL R8 3
0x7C180400, // 0028 CALL R6 2
0x8C180B0A, // 0029 GETMET R6 R5 K10
0x7C180200, // 002A CALL R6 1
0x80040A00, // 002B RET 1 R5
0x000C070B, // 002C ADD R3 R3 K11
0x7001FFD8, // 002D JMP #0007
0x80000000, // 002E RET 0
})
)
);