{"record":{"id":"aae5f20a191c84be","repo":"AlexxIT/go2rtc","slug":"wrong-message-checksum","errorCode":null,"errorMessage":"wrong message checksum","messagePattern":"wrong message checksum","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/roborock/iot/crypto.go","lineNumber":25,"sourceCode":"\t\"errors\"\n\t\"hash/crc32\"\n)\n\n// key - convert timestamp to key\nfunc (c *Codec) key(timestamp uint32) []byte {\n\tconst salt = \"TXdfu$jyZ#TZHsg4\"\n\tkey := md5.Sum([]byte(encodeTimestamp(timestamp) + c.devKey + salt))\n\treturn key[:]\n}\n\nfunc (c *Codec) Decrypt(cipherText []byte) ([]byte, error) {\n\tif len(cipherText) < 32 || string(cipherText[:3]) != \"1.0\" {\n\t\treturn nil, errors.New(\"wrong message prefix\")\n\t}\n\n\ti := len(cipherText) - 4\n\tif binary.BigEndian.Uint32(cipherText[i:]) != crc32.ChecksumIEEE(cipherText[:i]) {\n\t\treturn nil, errors.New(\"wrong message checksum\")\n\t}\n\n\tif proto := binary.BigEndian.Uint16(cipherText[15:]); proto != 102 {\n\t\treturn nil, nil\n\t}\n\n\ttimestamp := binary.BigEndian.Uint32(cipherText[11:])\n\treturn decryptECB(cipherText[19:i], c.key(timestamp)), nil\n}\n\nfunc (c *Codec) Encrypt(plainText []byte, seq, random, timestamp uint32) []byte {\n\tconst proto = 101\n\n\tcipherText := encryptECB(plainText, c.key(timestamp))\n\n\tsize := uint16(len(cipherText))\n\n\tmsg := make([]byte, 23+size)","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/roborock/iot/crypto.go#L7-L43","documentation":"Roborock IoT Decrypt integrity guard: the message passed the '1.0' prefix check, but the trailing CRC32 does not match the checksum of the body — the payload was corrupted or truncated in transit, or the framing is misaligned so the wrong bytes are treated as checksum.","triggerScenarios":"Thrown at pkg/roborock/iot/crypto.go:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reconnect and retry the request; transient transport corruption is common","Check for framing drift (short/long reads) in the connection reader","Verify devKey correctness if corruption is persistent"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}