Common stuff for all my devices' web server pages: css, login, log, ipv4, ipv6, firmware update, clock, reset info etc.

Dependents:   oldheating gps motorhome heating

Security

A password has to be set whenever there has been a software reset. Resets following faults or power on do not require a new password as the hash is restored from the RTC GPREG register.

The password is not saved on the device; instead a 32 bit hash of the password is saved. It would take 2^31 attempts to brute force the password: this could be done in under a month if an attempt were possible every millisecond. To prevent this a 200 ms delay is introduced in the reply to the login form, that gives a more reasonable 13 years to brute force the password.

Once the password is accepted a random session id is created. This is 36 bit to give six base 64 characters but without an extra delay. If an attempt could be made every ms then this would still take over a year to brute force.

The most likely attack would to use a dictionary with, say, 10 million entries against the password which would still take 20 days to do.

Committer:
andrewboyson
Date:
Wed Jul 31 15:09:15 2019 +0000
Revision:
127:bd6dd135009d
Parent:
110:8ab752842d25
Child:
145:d2bd78be00b2
Amalgamated Reply into Poll function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 96:eb2eb75bad0f 1 "//Net class\n"
andrewboyson 96:eb2eb75bad0f 2 "'use strict';\n"
andrewboyson 96:eb2eb75bad0f 3 "\n"
andrewboyson 96:eb2eb75bad0f 4 "class Net\n"
andrewboyson 96:eb2eb75bad0f 5 "{\n"
andrewboyson 96:eb2eb75bad0f 6 " static makeIp4(text)\n"
andrewboyson 96:eb2eb75bad0f 7 " {\n"
andrewboyson 96:eb2eb75bad0f 8 " let result = '';\n"
andrewboyson 96:eb2eb75bad0f 9 " result += parseInt(text.substr(6, 2), 16).toString();\n"
andrewboyson 96:eb2eb75bad0f 10 " result += '.';\n"
andrewboyson 96:eb2eb75bad0f 11 " result += parseInt(text.substr(4, 2), 16).toString();\n"
andrewboyson 96:eb2eb75bad0f 12 " result += '.';\n"
andrewboyson 96:eb2eb75bad0f 13 " result += parseInt(text.substr(2, 2), 16).toString();\n"
andrewboyson 96:eb2eb75bad0f 14 " result += '.';\n"
andrewboyson 96:eb2eb75bad0f 15 " result += parseInt(text.substr(0, 2), 16).toString();\n"
andrewboyson 96:eb2eb75bad0f 16 " return result;\n"
andrewboyson 96:eb2eb75bad0f 17 " }\n"
andrewboyson 96:eb2eb75bad0f 18 " static makeMac(text)\n"
andrewboyson 96:eb2eb75bad0f 19 " {\n"
andrewboyson 96:eb2eb75bad0f 20 " text = text.toLowerCase();\n"
andrewboyson 96:eb2eb75bad0f 21 " let result = '';\n"
andrewboyson 96:eb2eb75bad0f 22 " result += text.substr( 0, 2);\n"
andrewboyson 96:eb2eb75bad0f 23 " result += ':';\n"
andrewboyson 96:eb2eb75bad0f 24 " result += text.substr( 2, 2);\n"
andrewboyson 96:eb2eb75bad0f 25 " result += ':';\n"
andrewboyson 96:eb2eb75bad0f 26 " result += text.substr( 4, 2);\n"
andrewboyson 96:eb2eb75bad0f 27 " result += ':';\n"
andrewboyson 96:eb2eb75bad0f 28 " result += text.substr( 6, 2);\n"
andrewboyson 96:eb2eb75bad0f 29 " result += ':';\n"
andrewboyson 96:eb2eb75bad0f 30 " result += text.substr( 8, 2);\n"
andrewboyson 96:eb2eb75bad0f 31 " result += ':';\n"
andrewboyson 96:eb2eb75bad0f 32 " result += text.substr(10, 2);\n"
andrewboyson 96:eb2eb75bad0f 33 " return result;\n"
andrewboyson 96:eb2eb75bad0f 34 " }\n"
andrewboyson 96:eb2eb75bad0f 35 "\n"
andrewboyson 96:eb2eb75bad0f 36 " static hexToBit(text, iBit)\n"
andrewboyson 96:eb2eb75bad0f 37 " {\n"
andrewboyson 96:eb2eb75bad0f 38 " let value = parseInt(text, 16);\n"
andrewboyson 96:eb2eb75bad0f 39 " value >>= iBit;\n"
andrewboyson 96:eb2eb75bad0f 40 " return value & 1;\n"
andrewboyson 96:eb2eb75bad0f 41 " }\n"
andrewboyson 96:eb2eb75bad0f 42 " static makeIp6(text)\n"
andrewboyson 96:eb2eb75bad0f 43 " {\n"
andrewboyson 96:eb2eb75bad0f 44 " function makeWord(text)\n"
andrewboyson 96:eb2eb75bad0f 45 " {\n"
andrewboyson 96:eb2eb75bad0f 46 " let word = parseInt(text, 16);\n"
andrewboyson 96:eb2eb75bad0f 47 " if (word === 0) return '';\n"
andrewboyson 96:eb2eb75bad0f 48 " return word.toString(16);\n"
andrewboyson 96:eb2eb75bad0f 49 " }\n"
andrewboyson 96:eb2eb75bad0f 50 " text = text.toLowerCase();\n"
andrewboyson 96:eb2eb75bad0f 51 " let result = '';\n"
andrewboyson 96:eb2eb75bad0f 52 " result += makeWord(text.substr( 0, 4));\n"
andrewboyson 96:eb2eb75bad0f 53 " result += ':';\n"
andrewboyson 96:eb2eb75bad0f 54 " result += makeWord(text.substr( 4, 4));\n"
andrewboyson 96:eb2eb75bad0f 55 " result += ':';\n"
andrewboyson 96:eb2eb75bad0f 56 " result += makeWord(text.substr( 8, 4));\n"
andrewboyson 96:eb2eb75bad0f 57 " result += ':';\n"
andrewboyson 96:eb2eb75bad0f 58 " result += makeWord(text.substr(12, 4));\n"
andrewboyson 96:eb2eb75bad0f 59 " result += ':';\n"
andrewboyson 96:eb2eb75bad0f 60 " result += makeWord(text.substr(16, 4));\n"
andrewboyson 96:eb2eb75bad0f 61 " result += ':';\n"
andrewboyson 96:eb2eb75bad0f 62 " result += makeWord(text.substr(20, 4));\n"
andrewboyson 96:eb2eb75bad0f 63 " result += ':';\n"
andrewboyson 96:eb2eb75bad0f 64 " result += makeWord(text.substr(24, 4));\n"
andrewboyson 96:eb2eb75bad0f 65 " result += ':';\n"
andrewboyson 96:eb2eb75bad0f 66 " result += makeWord(text.substr(28, 4));\n"
andrewboyson 96:eb2eb75bad0f 67 " return result;\n"
andrewboyson 96:eb2eb75bad0f 68 " }\n"
andrewboyson 96:eb2eb75bad0f 69 "}"