mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-11-26 10:26:29 -05:00
Introduce the Makefile variable DEFAULT_APP which should be the path to the device app binary to include in the obliagory slot 0. Build automatically: the default app, the new digest file mgmt_app_digest.h for the firmware which contains the digest of DEFAULT_APP, the default partition table, and all the tools necessary to generate this.
40 lines
802 B
C
40 lines
802 B
C
// Copyright (C) 2024 - Tillitis AB
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <tkey/io.h>
|
|
#include <tkey/lib.h>
|
|
|
|
#include "mgmt_app.h"
|
|
|
|
// Lock down what app can start from flash slot 0.
|
|
//
|
|
// To update this, compute the BLAKE2s digest of the device app
|
|
// binare, see the b2s tool.
|
|
#include "mgmt_app_digest.h"
|
|
|
|
static uint8_t current_app_digest[32];
|
|
|
|
int mgmt_app_init(uint8_t app_digest[32])
|
|
{
|
|
if (app_digest == NULL) {
|
|
return -1;
|
|
}
|
|
|
|
memcpy_s(current_app_digest, sizeof(current_app_digest), app_digest,
|
|
32);
|
|
|
|
return 0;
|
|
}
|
|
|
|
// Authenticate an management app
|
|
bool mgmt_app_authenticate(void)
|
|
{
|
|
return memeq(current_app_digest, allowed_app_digest, 32) != 0;
|
|
}
|
|
|
|
uint8_t *mgmt_app_allowed_digest(void)
|
|
{
|
|
return (uint8_t *)allowed_app_digest;
|
|
}
|