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:
Tue Sep 24 18:16:47 2019 +0000
Revision:
130:9a5b8fe308f1
Parent:
110:8ab752842d25
Child:
158:80441390de93
Added http

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 103:91194cc19bbb 1 #include <stdio.h>
andrewboyson 103:91194cc19bbb 2
andrewboyson 103:91194cc19bbb 3 #include "http.h"
andrewboyson 103:91194cc19bbb 4 #include "firmware.h"
andrewboyson 103:91194cc19bbb 5 #include "web-firmware.h"
andrewboyson 103:91194cc19bbb 6
andrewboyson 103:91194cc19bbb 7 void WebFirmwareAjax()
andrewboyson 103:91194cc19bbb 8 {
andrewboyson 103:91194cc19bbb 9 //Header
andrewboyson 103:91194cc19bbb 10 HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL);
andrewboyson 103:91194cc19bbb 11
andrewboyson 103:91194cc19bbb 12 //Upload status
andrewboyson 103:91194cc19bbb 13 if (FirmwareSentLength == FirmwareFileLength)
andrewboyson 103:91194cc19bbb 14 {
andrewboyson 103:91194cc19bbb 15 HttpAddText("Length ok\r\n");
andrewboyson 103:91194cc19bbb 16 }
andrewboyson 103:91194cc19bbb 17 else
andrewboyson 103:91194cc19bbb 18 {
andrewboyson 103:91194cc19bbb 19 HttpAddText("Length error\r\n");
andrewboyson 103:91194cc19bbb 20 HttpAddF (" sent %6d\r\n", FirmwareSentLength);
andrewboyson 103:91194cc19bbb 21 HttpAddF (" rcvd %6d\r\n", FirmwareRcvdLength);
andrewboyson 103:91194cc19bbb 22 HttpAddF (" file %6d\r\n", FirmwareFileLength);
andrewboyson 103:91194cc19bbb 23 }
andrewboyson 103:91194cc19bbb 24
andrewboyson 103:91194cc19bbb 25 //Save status
andrewboyson 103:91194cc19bbb 26 if (FirmwareFailed)
andrewboyson 103:91194cc19bbb 27 {
andrewboyson 103:91194cc19bbb 28 HttpAddText("Save failed - see log");
andrewboyson 103:91194cc19bbb 29 }
andrewboyson 103:91194cc19bbb 30 else
andrewboyson 103:91194cc19bbb 31 {
andrewboyson 103:91194cc19bbb 32 HttpAddText("Saved ok");
andrewboyson 103:91194cc19bbb 33 }
andrewboyson 103:91194cc19bbb 34
andrewboyson 103:91194cc19bbb 35 //Delimiter
andrewboyson 103:91194cc19bbb 36 HttpAddChar('\f');
andrewboyson 103:91194cc19bbb 37
andrewboyson 103:91194cc19bbb 38 //New directory list
andrewboyson 103:91194cc19bbb 39 WebFirmwareListSemihostFiles();
andrewboyson 103:91194cc19bbb 40 }