初始提交:terminalX 可运行态(M0/M1/M1.5 已真机验证)
- M0: libghostty SSH 终端(渲染/输入/连接)+ 白屏修复(OutputGate) + 会话状态机/自动重连 - M1: tsnet 用户态组网 + SSH-over-tsnet(fd 桥),shell 级真机验证;R5(Go+gvisor+C+++Swift 同进程) retire - M1.5: tmux -CC 原生 tab(MVP) - 结构: packages/(TXCore·TXTransport), apps/TerminalX, vendor/(libghostty-spm/libssh2/mbedtls/tsnet-bridge), artifacts/ - 文档: CLAUDE.md + docs/HANDOFF.md(新会话入口) - 环境: 认证代理→依赖 vendor 本地化;Go 在 ~/.local/go;仅模拟器/未签名 - 待续: M2 mosh, tmux 多 pane, M4 安全(host key/SE) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
75
vendor/mbedtls/framework/psasim/include/client.h
vendored
Normal file
75
vendor/mbedtls/framework/psasim/include/client.h
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
/* PSA Firmware Framework client header for psasim. */
|
||||
|
||||
/*
|
||||
* Copyright The Mbed TLS Contributors
|
||||
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef __PSA_CLIENT_H__
|
||||
#define __PSA_CLIENT_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "psa/crypto.h"
|
||||
|
||||
#include "error_ext.h"
|
||||
/*********************** PSA Client Macros and Types *************************/
|
||||
|
||||
#define PSA_FRAMEWORK_VERSION (0x0100)
|
||||
|
||||
#define PSA_VERSION_NONE (0)
|
||||
|
||||
/* PSA response types */
|
||||
#define PSA_CONNECTION_REFUSED PSA_ERROR_CONNECTION_REFUSED
|
||||
#define PSA_CONNECTION_BUSY PSA_ERROR_CONNECTION_BUSY
|
||||
#define PSA_DROP_CONNECTION PSA_ERROR_PROGRAMMER_ERROR
|
||||
|
||||
/* PSA message handles */
|
||||
#define PSA_NULL_HANDLE ((psa_handle_t) 0)
|
||||
|
||||
#define PSA_HANDLE_IS_VALID(handle) ((psa_handle_t) (handle) > 0)
|
||||
#define PSA_HANDLE_TO_ERROR(handle) ((psa_status_t) (handle))
|
||||
|
||||
/**
|
||||
* A read-only input memory region provided to an RoT Service.
|
||||
*/
|
||||
typedef struct psa_invec {
|
||||
const void *base;
|
||||
size_t len;
|
||||
} psa_invec;
|
||||
|
||||
/**
|
||||
* A writable output memory region provided to an RoT Service.
|
||||
*/
|
||||
typedef struct psa_outvec {
|
||||
void *base;
|
||||
size_t len;
|
||||
} psa_outvec;
|
||||
|
||||
/*************************** PSA Client API **********************************/
|
||||
|
||||
uint32_t psa_framework_version(void);
|
||||
|
||||
uint32_t psa_version(uint32_t sid);
|
||||
|
||||
psa_handle_t psa_connect(uint32_t sid, uint32_t version);
|
||||
|
||||
psa_status_t psa_call(psa_handle_t handle,
|
||||
int32_t type,
|
||||
const psa_invec *in_vec,
|
||||
size_t in_len,
|
||||
psa_outvec *out_vec,
|
||||
size_t out_len);
|
||||
|
||||
void psa_close(psa_handle_t handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PSA_CLIENT_H__ */
|
||||
52
vendor/mbedtls/framework/psasim/include/common.h
vendored
Normal file
52
vendor/mbedtls/framework/psasim/include/common.h
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/* Common definitions used for clients and services */
|
||||
|
||||
/*
|
||||
* Copyright The Mbed TLS Contributors
|
||||
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef _COMMON_H_
|
||||
#define _COMMON_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* Increasing this might break on some platforms */
|
||||
#define MAX_FRAGMENT_SIZE 200
|
||||
|
||||
#define CONNECT_REQUEST 1
|
||||
#define CALL_REQUEST 2
|
||||
#define CLOSE_REQUEST 3
|
||||
#define VERSION_REQUEST 4
|
||||
#define READ_REQUEST 5
|
||||
#define READ_RESPONSE 6
|
||||
#define WRITE_REQUEST 7
|
||||
#define WRITE_RESPONSE 8
|
||||
#define SKIP_REQUEST 9
|
||||
#define PSA_REPLY 10
|
||||
|
||||
#define NON_SECURE (1 << 30)
|
||||
|
||||
typedef int32_t psa_handle_t;
|
||||
|
||||
#define PSA_MAX_IOVEC (4u)
|
||||
|
||||
#define PSA_IPC_CALL (0)
|
||||
|
||||
struct message_text {
|
||||
int qid;
|
||||
int32_t psa_type;
|
||||
char buf[MAX_FRAGMENT_SIZE];
|
||||
};
|
||||
|
||||
struct message {
|
||||
long message_type;
|
||||
struct message_text message_text;
|
||||
};
|
||||
|
||||
typedef struct vector_sizes {
|
||||
size_t invec_sizes[PSA_MAX_IOVEC];
|
||||
size_t outvec_sizes[PSA_MAX_IOVEC];
|
||||
} vector_sizes_t;
|
||||
|
||||
#endif /* _COMMON_H_ */
|
||||
19
vendor/mbedtls/framework/psasim/include/error_ext.h
vendored
Normal file
19
vendor/mbedtls/framework/psasim/include/error_ext.h
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/* PSA status codes used by psasim. */
|
||||
|
||||
/*
|
||||
* Copyright The Mbed TLS Contributors
|
||||
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef PSA_ERROR_H
|
||||
#define PSA_ERROR_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define PSA_ERROR_PROGRAMMER_ERROR ((psa_status_t) -129)
|
||||
#define PSA_ERROR_CONNECTION_REFUSED ((psa_status_t) -130)
|
||||
#define PSA_ERROR_CONNECTION_BUSY ((psa_status_t) -131)
|
||||
|
||||
#endif
|
||||
15
vendor/mbedtls/framework/psasim/include/init.h
vendored
Normal file
15
vendor/mbedtls/framework/psasim/include/init.h
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/* Declarations of internal functions. */
|
||||
|
||||
/*
|
||||
* Copyright The Mbed TLS Contributors
|
||||
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <service.h>
|
||||
void raise_signal(psa_signal_t signal);
|
||||
void __init_psasim(const char **array,
|
||||
int size,
|
||||
const int allow_ns_clients_array[32],
|
||||
const uint32_t versions[32],
|
||||
const int strict_policy_array[32]);
|
||||
17
vendor/mbedtls/framework/psasim/include/lifecycle.h
vendored
Normal file
17
vendor/mbedtls/framework/psasim/include/lifecycle.h
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/* PSA lifecycle states used by psasim. */
|
||||
|
||||
/*
|
||||
* Copyright The Mbed TLS Contributors
|
||||
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#define PSA_LIFECYCLE_PSA_STATE_MASK (0xff00u)
|
||||
#define PSA_LIFECYCLE_IMP_STATE_MASK (0x00ffu)
|
||||
#define PSA_LIFECYCLE_UNKNOWN (0x0000u)
|
||||
#define PSA_LIFECYCLE_ASSEMBLY_AND_TEST (0x1000u)
|
||||
#define PSA_LIFECYCLE_PSA_ROT_PROVISIONING (0x2000u)
|
||||
#define PSA_LIFECYCLE_SECURED (0x3000u)
|
||||
#define PSA_LIFECYCLE_NON_PSA_ROT_DEBUG (0x4000u)
|
||||
#define PSA_LIFECYCLE_RECOVERABLE_PSA_ROT_DEBUG (0x5000u)
|
||||
#define PSA_LIFECYCLE_DECOMMISSIONED (0x6000u)
|
||||
#define psa_rot_lifecycle_state(void) PSA_LIFECYCLE_UNKNOWN
|
||||
253
vendor/mbedtls/framework/psasim/include/service.h
vendored
Normal file
253
vendor/mbedtls/framework/psasim/include/service.h
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
/* PSA Firmware Framework service header for psasim. */
|
||||
|
||||
/*
|
||||
* Copyright The Mbed TLS Contributors
|
||||
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef __PSA_SERVICE_H__
|
||||
#define __PSA_SERVICE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "psa/crypto.h"
|
||||
|
||||
/********************** PSA Secure Partition Macros and Types ****************/
|
||||
|
||||
/* PSA wait timeouts */
|
||||
#define PSA_POLL (0x00000000u)
|
||||
#define PSA_BLOCK (0x80000000u)
|
||||
|
||||
/* A mask value that includes all Secure Partition signals */
|
||||
#define PSA_WAIT_ANY (~0u)
|
||||
|
||||
/* Doorbell signal */
|
||||
#define PSA_DOORBELL (0x00000008u)
|
||||
|
||||
/* PSA message types */
|
||||
#define PSA_IPC_CONNECT (-1)
|
||||
#define PSA_IPC_DISCONNECT (-2)
|
||||
|
||||
/* Return code from psa_get() */
|
||||
#define PSA_ERR_NOMSG (INT32_MIN + 3)
|
||||
|
||||
/* Store a set of one or more Secure Partition signals */
|
||||
typedef uint32_t psa_signal_t;
|
||||
|
||||
/**
|
||||
* Describe a message received by an RoT Service after calling \ref psa_get().
|
||||
*/
|
||||
typedef struct psa_msg_t {
|
||||
uint32_t type; /* One of the following values:
|
||||
* \ref PSA_IPC_CONNECT
|
||||
* \ref PSA_IPC_CALL
|
||||
* \ref PSA_IPC_DISCONNECT
|
||||
*/
|
||||
psa_handle_t handle; /* A reference generated by the SPM to the
|
||||
* message returned by psa_get().
|
||||
*/
|
||||
int32_t client_id; /* Partition ID of the sender of the message */
|
||||
void *rhandle; /* Be useful for binding a connection to some
|
||||
* application-specific data or function
|
||||
* pointer within the RoT Service
|
||||
* implementation.
|
||||
*/
|
||||
size_t in_size[PSA_MAX_IOVEC]; /* Provide the size of each client input
|
||||
* vector in bytes.
|
||||
*/
|
||||
size_t out_size[PSA_MAX_IOVEC];/* Provide the size of each client output
|
||||
* vector in bytes.
|
||||
*/
|
||||
} psa_msg_t;
|
||||
|
||||
/************************* PSA Secure Partition API **************************/
|
||||
|
||||
/**
|
||||
* \brief Return the Secure Partition interrupt signals that have been asserted
|
||||
* from a subset of signals provided by the caller.
|
||||
*
|
||||
* \param[in] signal_mask A set of signals to query. Signals that are not
|
||||
* in this set will be ignored.
|
||||
* \param[in] timeout Specify either blocking \ref PSA_BLOCK or
|
||||
* polling \ref PSA_POLL operation.
|
||||
*
|
||||
* \retval >0 At least one signal is asserted.
|
||||
* \retval 0 No signals are asserted. This is only seen when
|
||||
* a polling timeout is used.
|
||||
*/
|
||||
psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* \brief Retrieve the message which corresponds to a given RoT Service signal
|
||||
* and remove the message from the RoT Service queue.
|
||||
*
|
||||
* \param[in] signal The signal value for an asserted RoT Service.
|
||||
* \param[out] msg Pointer to \ref psa_msg_t object for receiving
|
||||
* the message.
|
||||
*
|
||||
* \retval PSA_SUCCESS Success, *msg will contain the delivered
|
||||
* message.
|
||||
* \retval PSA_ERR_NOMSG Message could not be delivered.
|
||||
* \retval "Does not return" The call is invalid because one or more of the
|
||||
* following are true:
|
||||
* \arg signal has more than a single bit set.
|
||||
* \arg signal does not correspond to an RoT Service.
|
||||
* \arg The RoT Service signal is not currently
|
||||
* asserted.
|
||||
* \arg The msg pointer provided is not a valid memory
|
||||
* reference.
|
||||
*/
|
||||
psa_status_t psa_get(psa_signal_t signal, psa_msg_t *msg);
|
||||
|
||||
/**
|
||||
* \brief Associate some RoT Service private data with a client connection.
|
||||
*
|
||||
* \param[in] msg_handle Handle for the client's message.
|
||||
* \param[in] rhandle Reverse handle allocated by the RoT Service.
|
||||
*
|
||||
* \retval void Success, rhandle will be provided with all
|
||||
* subsequent messages delivered on this
|
||||
* connection.
|
||||
* \retval "Does not return" msg_handle is invalid.
|
||||
*/
|
||||
void psa_set_rhandle(psa_handle_t msg_handle, void *rhandle);
|
||||
|
||||
/**
|
||||
* \brief Read a message parameter or part of a message parameter from a client
|
||||
* input vector.
|
||||
*
|
||||
* \param[in] msg_handle Handle for the client's message.
|
||||
* \param[in] invec_idx Index of the input vector to read from. Must be
|
||||
* less than \ref PSA_MAX_IOVEC.
|
||||
* \param[out] buffer Buffer in the Secure Partition to copy the
|
||||
* requested data to.
|
||||
* \param[in] num_bytes Maximum number of bytes to be read from the
|
||||
* client input vector.
|
||||
*
|
||||
* \retval >0 Number of bytes copied.
|
||||
* \retval 0 There was no remaining data in this input
|
||||
* vector.
|
||||
* \retval "Does not return" The call is invalid, one or more of the
|
||||
* following are true:
|
||||
* \arg msg_handle is invalid.
|
||||
* \arg msg_handle does not refer to a
|
||||
* \ref PSA_IPC_CALL message.
|
||||
* \arg invec_idx is equal to or greater than
|
||||
* \ref PSA_MAX_IOVEC.
|
||||
* \arg the memory reference for buffer is invalid or
|
||||
* not writable.
|
||||
*/
|
||||
size_t psa_read(psa_handle_t msg_handle, uint32_t invec_idx,
|
||||
void *buffer, size_t num_bytes);
|
||||
|
||||
/**
|
||||
* \brief Skip over part of a client input vector.
|
||||
*
|
||||
* \param[in] msg_handle Handle for the client's message.
|
||||
* \param[in] invec_idx Index of input vector to skip from. Must be
|
||||
* less than \ref PSA_MAX_IOVEC.
|
||||
* \param[in] num_bytes Maximum number of bytes to skip in the client
|
||||
* input vector.
|
||||
*
|
||||
* \retval >0 Number of bytes skipped.
|
||||
* \retval 0 There was no remaining data in this input
|
||||
* vector.
|
||||
* \retval "Does not return" The call is invalid, one or more of the
|
||||
* following are true:
|
||||
* \arg msg_handle is invalid.
|
||||
* \arg msg_handle does not refer to a
|
||||
* \ref PSA_IPC_CALL message.
|
||||
* \arg invec_idx is equal to or greater than
|
||||
* \ref PSA_MAX_IOVEC.
|
||||
*/
|
||||
size_t psa_skip(psa_handle_t msg_handle, uint32_t invec_idx, size_t num_bytes);
|
||||
|
||||
/**
|
||||
* \brief Write a message response to a client output vector.
|
||||
*
|
||||
* \param[in] msg_handle Handle for the client's message.
|
||||
* \param[out] outvec_idx Index of output vector in message to write to.
|
||||
* Must be less than \ref PSA_MAX_IOVEC.
|
||||
* \param[in] buffer Buffer with the data to write.
|
||||
* \param[in] num_bytes Number of bytes to write to the client output
|
||||
* vector.
|
||||
*
|
||||
* \retval void Success
|
||||
* \retval "Does not return" The call is invalid, one or more of the
|
||||
* following are true:
|
||||
* \arg msg_handle is invalid.
|
||||
* \arg msg_handle does not refer to a
|
||||
* \ref PSA_IPC_CALL message.
|
||||
* \arg outvec_idx is equal to or greater than
|
||||
* \ref PSA_MAX_IOVEC.
|
||||
* \arg The memory reference for buffer is invalid.
|
||||
* \arg The call attempts to write data past the end
|
||||
* of the client output vector.
|
||||
*/
|
||||
void psa_write(psa_handle_t msg_handle, uint32_t outvec_idx,
|
||||
const void *buffer, size_t num_bytes);
|
||||
|
||||
/**
|
||||
* \brief Complete handling of a specific message and unblock the client.
|
||||
*
|
||||
* \param[in] msg_handle Handle for the client's message.
|
||||
* \param[in] status Message result value to be reported to the
|
||||
* client.
|
||||
*
|
||||
* \retval void Success.
|
||||
* \retval "Does not return" The call is invalid, one or more of the
|
||||
* following are true:
|
||||
* \arg msg_handle is invalid.
|
||||
* \arg An invalid status code is specified for the
|
||||
* type of message.
|
||||
*/
|
||||
void psa_reply(psa_handle_t msg_handle, psa_status_t status);
|
||||
|
||||
/**
|
||||
* \brief Send a PSA_DOORBELL signal to a specific Secure Partition.
|
||||
*
|
||||
* \param[in] partition_id Secure Partition ID of the target partition.
|
||||
*
|
||||
* \retval void Success.
|
||||
* \retval "Does not return" partition_id does not correspond to a Secure
|
||||
* Partition.
|
||||
*/
|
||||
void psa_notify(int32_t partition_id);
|
||||
|
||||
/**
|
||||
* \brief Clear the PSA_DOORBELL signal.
|
||||
*
|
||||
* \retval void Success.
|
||||
* \retval "Does not return" The Secure Partition's doorbell signal is not
|
||||
* currently asserted.
|
||||
*/
|
||||
void psa_clear(void);
|
||||
|
||||
/**
|
||||
* \brief Inform the SPM that an interrupt has been handled (end of interrupt).
|
||||
*
|
||||
* \param[in] irq_signal The interrupt signal that has been processed.
|
||||
*
|
||||
* \retval void Success.
|
||||
* \retval "Does not return" The call is invalid, one or more of the
|
||||
* following are true:
|
||||
* \arg irq_signal is not an interrupt signal.
|
||||
* \arg irq_signal indicates more than one signal.
|
||||
* \arg irq_signal is not currently asserted.
|
||||
*/
|
||||
void psa_eoi(psa_signal_t irq_signal);
|
||||
|
||||
#define psa_panic(X) abort();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PSA_SERVICE_H__ */
|
||||
33
vendor/mbedtls/framework/psasim/include/util.h
vendored
Normal file
33
vendor/mbedtls/framework/psasim/include/util.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Common definitions used for clients and services */
|
||||
|
||||
/*
|
||||
* Copyright The Mbed TLS Contributors
|
||||
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "service.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define PRINT(fmt, ...) \
|
||||
fprintf(stdout, fmt "\n", ##__VA_ARGS__)
|
||||
|
||||
#if defined(DEBUG)
|
||||
#define INFO(fmt, ...) \
|
||||
fprintf(stdout, "Info (%s - %d): " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__)
|
||||
#else /* !DEBUG */
|
||||
#define INFO(...)
|
||||
#endif /* DEBUG*/
|
||||
|
||||
#define ERROR(fmt, ...) \
|
||||
fprintf(stderr, "Error (%s - %d): " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__)
|
||||
|
||||
#define FATAL(fmt, ...) \
|
||||
{ \
|
||||
fprintf(stderr, "Fatal (%s - %d): " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); \
|
||||
abort(); \
|
||||
}
|
||||
|
||||
#define PROJECT_ID 'M'
|
||||
#define PATHNAMESIZE 256
|
||||
#define TMP_FILE_BASE_PATH "./"
|
||||
Reference in New Issue
Block a user