53 lines
1.7 KiB
C
53 lines
1.7 KiB
C
/*
|
|||
|
|
* SPDX-License-Identifier: LicenseRef-Unisoc-General-1.0
|
||
|
|
*
|
||
|
|
* Copyright 2016-2024 Unisoc (Shanghai) Technologies Co., Ltd
|
||
|
|
*
|
||
|
|
* Licensed under the Unisoc General Software License, version 1.0 (the License);
|
||
|
|
* You may not use this file except in compliance with the License.
|
||
|
|
* You may obtain a copy of the License at
|
||
|
|
*
|
||
|
|
* https://www.unisoc.com/en_us/license/UNISOC_GENERAL_LICENSE_V1.0-EN_US
|
||
|
|
*
|
||
|
|
* Software distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
|
* WITHOUT WARRANTIES OF ANY KIND, either express or implied.
|
||
|
|
* See the Unisoc General Software License, version 1.0 for more details.
|
||
|
|
*/
|
||
|
|
|
||
|
|
#pragma once
|
||
|
|
|
||
|
|
#define ANTI_ROLLBACK_PORT "com.linux.trusty.antirollback"
|
||
|
|
#define ANTI_ROLLBACK_MAX_BUFFER_LENGTH 4096
|
||
|
|
|
||
|
|
typedef unsigned int uint32_t;
|
||
|
|
typedef unsigned short uint16_t;
|
||
|
|
typedef unsigned char uint8_t;
|
||
|
|
|
||
|
|
// Commands
|
||
|
|
enum anti_rollback_command {
|
||
|
|
ANTI_ROLLBACK_BIT = 1,
|
||
|
|
ANTI_ROLLBACK_REQ_SHIFT = 1,
|
||
|
|
|
||
|
|
ANTI_ROLLBACK_CMD = (0 << ANTI_ROLLBACK_REQ_SHIFT),
|
||
|
|
ANTI_ROLLBACK_VERIFY = (1 << ANTI_ROLLBACK_REQ_SHIFT),
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* anti_rollback_message
|
||
|
|
* @cmd: the command, one of keygen_command.
|
||
|
|
* @payload: start of the serialized command specific payload
|
||
|
|
*/
|
||
|
|
typedef struct trusty_anti_rollback_message {
|
||
|
|
uint32_t cmd;
|
||
|
|
uint8_t payload[0];
|
||
|
|
} anti_rollback_message;
|
||
|
|
|
||
|
|
|
||
|
|
int trusty_anti_rollback_connect(void);
|
||
|
|
int trusty_anti_rollback_call(uint32_t cmd, void *in, uint32_t in_size, uint8_t *out,
|
||
|
|
uint32_t *out_size);
|
||
|
|
void trusty_anti_rollback_disconnect(void);
|
||
|
|
int update_rootfs_verison(uint8_t *data, uint32_t *size, uint8_t* out);
|
||
|
|
int verify_data(uint8_t *data, uint32_t size, uint8_t* out, uint32_t *out_size);
|
||
|
|
|