1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-12-22 18:01:10 +02:00

fw/: move secrets to secret.c; rename reset secret to maintenance secret

This commit is contained in:
Werner Almesberger 2012-07-01 09:54:45 -03:00
parent 1a8bfd4684
commit 6fac517d48
7 changed files with 61 additions and 20 deletions

View File

@ -31,7 +31,7 @@ OBJCOPY = $(AVR_PREFIX)objcopy
SIZE = $(AVR_PREFIX)size
OBJS = $(NAME).o accel.o dispatch.o hash.o image.o param.o \
reset.o sample.o sweep.o \
reset.o sample.o secret.o sweep.o \
$(COMMON_OBJS)
BOOT_OBJS = boot.o flash.o fw.o $(COMMON_OBJS)
COMMON_OBJS = rf.o spi.o

View File

@ -15,12 +15,11 @@
#include <stdint.h>
#include <string.h>
#include <avr/pgmspace.h>
#include "io.h"
#include "hash.h"
#include "proto.h"
#include "dispatch.h"
#include "secret.h"
#include "image.h"
@ -32,11 +31,6 @@ static bool failed;
const struct line *image = images[0];
const uint8_t image_secret[2*PAYLOAD] PROGMEM = {
#include "image-secret.inc"
};
#define MAP(port, value, group) ( \
((value) & 1 ? MASK(port, LED_##group##1) : 0) | \
((value) & 2 ? MASK(port, LED_##group##2) : 0) | \

View File

@ -14,13 +14,8 @@
#ifndef IMAGE_H
#define IMAGE_H
#include <stdbool.h>
#include <stdint.h>
#include <avr/pgmspace.h>
#include "proto.h"
struct line {
uint8_t d; /* port D0-D7 */
@ -29,6 +24,5 @@ struct line {
extern const struct line *image;
extern const uint8_t image_secret[2*PAYLOAD] PROGMEM;
#endif /* !IMAGE_H */

View File

@ -19,7 +19,7 @@
#include "hash.h"
#include "sweep.h"
#include "image.h"
#include "secret.h"
#include "proto.h"
#include "dispatch.h"

View File

@ -20,6 +20,7 @@
#include "proto.h"
#include "dispatch.h"
#include "secret.h"
/*
@ -34,14 +35,10 @@
* intercept the secret(s) either way.
*/
static const uint8_t reset_secret[PAYLOAD] PROGMEM = {
#include "unlock-secret.inc"
};
static bool reset_first(uint8_t limit, const uint8_t *payload)
{
if (memcmp_P(payload, reset_secret, PAYLOAD))
if (memcmp_P(payload, maint_secret, PAYLOAD))
return 0;
WDTCSR = 1 << WDE;
return 1;

29
fw/secret.c Normal file
View File

@ -0,0 +1,29 @@
/*
* fw/secret.c - Shared authentication secrets
*
* Written 2012 by Werner Almesberger
* Copyright 2012 Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <stdint.h>
#include <avr/pgmspace.h>
#include "proto.h"
#include "secret.h"
const uint8_t maint_secret[PAYLOAD] PROGMEM = {
#include "unlock-secret.inc"
};
const uint8_t image_secret[2*PAYLOAD] PROGMEM = {
#include "image-secret.inc"
};

27
fw/secret.h Normal file
View File

@ -0,0 +1,27 @@
/*
* fw/secret.h - Shared authentication secrets
*
* Written 2012 by Werner Almesberger
* Copyright 2012 Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef SECRET_H
#define SECRET_H
#include <stdint.h>
#include <avr/pgmspace.h>
#include "proto.h"
extern const uint8_t maint_secret[PAYLOAD] PROGMEM;
extern const uint8_t image_secret[2*PAYLOAD] PROGMEM;
#endif /* !SECRET_H */