|
PQS: Post Quantum Shell Protocol 1.1.0.0a (A2)
A quantum secure secure shell protocol
|
PQS native file-transfer helpers. More...
#include "pqscommon.h"#include <stdio.h>Go to the source code of this file.
Typedefs | |
| typedef enum pqs_xfer_walk_events | pqs_xfer_walk_events |
| typedef bool(* | pqs_xfer_walk_callback) (pqs_xfer_walk_events event, const char *localpath, const char *relative, void *context) |
| File-transfer directory walk callback. | |
Enumerations | |
| enum | pqs_xfer_walk_events { pqs_xfer_walk_event_directory_begin = 0x01U , pqs_xfer_walk_event_file = 0x02U , pqs_xfer_walk_event_directory_end = 0x03U } |
| File-transfer directory walk event types. More... | |
Functions | |
| PQS_EXPORT_API size_t | pqs_xfer_payload_size (const uint8_t *message, size_t msglen) |
| Return the plaintext payload length carried after the PQS application message header. | |
| PQS_EXPORT_API void | pqs_xfer_join_path (char *output, size_t outlen, const char *first, const char *second) |
| Join two local file-system path components. | |
| PQS_EXPORT_API void | pqs_xfer_join_remote (char *output, size_t outlen, const char *first, const char *second) |
| Join two remote transfer path components using the PQS remote delimiter. | |
| PQS_EXPORT_API bool | pqs_xfer_local_path_is_directory (const char *path) |
| Test whether a local path is a directory. | |
| PQS_EXPORT_API bool | pqs_xfer_create_parent_directories (const char *fpath) |
| Create all parent directories for a local output path. | |
| PQS_EXPORT_API bool | pqs_xfer_make_local_recursive_path (char *output, size_t outlen, const char *root, const char *relative) |
| Build a local path for a recursive transfer member. | |
| PQS_EXPORT_API bool | pqs_xfer_walk_directory (const char *localroot, const char *remoteroot, size_t maxdepth, pqs_xfer_walk_callback callback, void *context) |
| Walk a local directory tree and report PQS transfer paths through a callback. | |
| PQS_EXPORT_API bool | pqs_xfer_make_path (char *output, size_t outlen, const char *root, const char *relative) |
| Build a confined absolute path from a transfer root and a relative remote path. | |
| PQS_EXPORT_API bool | pqs_xfer_extract_relative (char *output, size_t outlen, const uint8_t *message, size_t msglen) |
| Extract a bounded relative path from a file-transfer application message. | |
| PQS_EXPORT_API bool | pqs_xfer_path_is_confined (const char *root, const char *path, bool existing) |
| Test whether a local path resolves inside the configured root. | |
| PQS_EXPORT_API bool | pqs_xfer_path_is_safe (const char *relative) |
| Test whether a remote file-transfer path is safe. | |
| PQS_EXPORT_API bool | pqs_xfer_make_user_root (char *output, size_t outlen, const char *root, const char *username) |
| Build a per-user transfer root path. | |
| PQS_EXPORT_API FILE * | pqs_xfer_open_read_confined (const char *root, const char *relative) |
| Open a confined transfer file for binary reading. | |
| PQS_EXPORT_API FILE * | pqs_xfer_open_write_confined (const char *root, const char *relative) |
| Open a confined transfer file for binary writing. | |
| PQS_EXPORT_API bool | pqs_xfer_make_temporary_path (char *output, size_t outlen, const char *relative) |
| Build a confined temporary upload path from a relative target path. | |
| PQS_EXPORT_API bool | pqs_xfer_remove_confined (const char *root, const char *relative) |
| Remove a confined file inside the configured transfer root. | |
| PQS_EXPORT_API bool | pqs_xfer_make_directory_confined (const char *root, const char *relative) |
| Create a confined directory inside the configured transfer root. | |
| PQS_EXPORT_API bool | pqs_xfer_publish_temporary_file (const char *root, const char *temporary, const char *relative) |
| Publish a staged temporary upload as its final confined file. | |
| PQS_EXPORT_API bool | pqs_xfer_hash_file (const char *fpath, char *hexhash, size_t hexlen, size_t *filesize) |
| Compute the SHA3-256 hash of a local file. | |
| PQS_EXPORT_API bool | pqs_xfer_format_metadata (char *output, size_t outlen, size_t filesize, const char *hexhash) |
| Format file-transfer metadata text. | |
| PQS_EXPORT_API bool | pqs_xfer_parse_metadata (const char *metadata, size_t *filesize, char *hexhash, size_t hexlen) |
| Parse file-transfer metadata text. | |
| PQS_EXPORT_API bool | pqs_xfer_format_file_metadata (char *output, size_t outlen, const char *relative, size_t filesize, const char *hexhash) |
| Format recursive file-transfer metadata text. | |
| PQS_EXPORT_API bool | pqs_xfer_parse_file_metadata (const char *metadata, char *relative, size_t relen, size_t *filesize, char *hexhash, size_t hexlen) |
| Parse recursive file-transfer metadata text. | |
| PQS_EXPORT_API bool | pqs_xfer_path_is_symlink (const char *path) |
| Test whether a file-system path is a symbolic link or reparse point. | |
PQS native file-transfer helpers.
| typedef bool(* pqs_xfer_walk_callback) (pqs_xfer_walk_events event, const char *localpath, const char *relative, void *context) |
File-transfer directory walk callback.
| event | The directory-walk event type. |
| localpath | [const] The local file-system path for the event. |
| relative | [const] The relative PQS transfer path for the event. |
| context | [void] An application-defined callback context. |
| enum pqs_xfer_walk_events |
File-transfer directory walk event types.
| PQS_EXPORT_API bool pqs_xfer_extract_relative | ( | char * | output, |
| size_t | outlen, | ||
| const uint8_t * | message, | ||
| size_t | msglen ) |
Extract a bounded relative path from a file-transfer application message.
| output | [char] The output path buffer. |
| outlen | The length of the output path buffer. |
| message | [const] The application message buffer. |
| msglen | The application message length. |
| PQS_EXPORT_API bool pqs_xfer_format_file_metadata | ( | char * | output, |
| size_t | outlen, | ||
| const char * | relative, | ||
| size_t | filesize, | ||
| const char * | hexhash ) |
Format recursive file-transfer metadata text.
| output | [char] The output metadata buffer. |
| outlen | The length of the output metadata buffer. |
| relative | [const] The relative file path inside the recursive transfer root. |
| filesize | The file size associated with the transfer. |
| hexhash | [const] The NUL-terminated SHA3-256 hexadecimal hash. |
| PQS_EXPORT_API bool pqs_xfer_format_metadata | ( | char * | output, |
| size_t | outlen, | ||
| size_t | filesize, | ||
| const char * | hexhash ) |
Format file-transfer metadata text.
| output | [char] The output metadata buffer. |
| outlen | The length of the output metadata buffer. |
| filesize | The file size associated with the transfer. |
| hexhash | [const] The NUL-terminated SHA3-256 hexadecimal hash. |
| PQS_EXPORT_API bool pqs_xfer_hash_file | ( | const char * | fpath, |
| char * | hexhash, | ||
| size_t | hexlen, | ||
| size_t * | filesize ) |
Compute the SHA3-256 hash of a local file.
| fpath | [const] The local file path. |
| hexhash | [char] The output hexadecimal hash buffer. |
| hexlen | The length of the output hexadecimal hash buffer. |
| filesize | [size_t] An optional output parameter receiving the file size. |
| PQS_EXPORT_API bool pqs_xfer_make_directory_confined | ( | const char * | root, |
| const char * | relative ) |
Create a confined directory inside the configured transfer root.
| root | [const] The configured transfer root directory. |
| relative | [const] The relative directory path to create. |
| PQS_EXPORT_API bool pqs_xfer_make_path | ( | char * | output, |
| size_t | outlen, | ||
| const char * | root, | ||
| const char * | relative ) |
Build a confined absolute path from a transfer root and a relative remote path.
| output | [char] The output path buffer. |
| outlen | The length of the output path buffer. |
| root | [const] The configured transfer root directory. |
| relative | [const] The remote path supplied by the peer. |
| PQS_EXPORT_API bool pqs_xfer_make_temporary_path | ( | char * | output, |
| size_t | outlen, | ||
| const char * | relative ) |
Build a confined temporary upload path from a relative target path.
The temporary path remains relative to the same transfer root and is suitable for writing a staged upload before final hash verification.
| output | [char] The output relative temporary path. |
| outlen | The length of the output path buffer. |
| relative | [const] The final relative target path. |
| PQS_EXPORT_API bool pqs_xfer_make_user_root | ( | char * | output, |
| size_t | outlen, | ||
| const char * | root, | ||
| const char * | username ) |
Build a per-user transfer root path.
| output | [char] The output path buffer. |
| outlen | The length of the output path buffer. |
| root | [const] The configured global transfer root directory. |
| username | [const] The authenticated PQS user name. |
| PQS_EXPORT_API FILE * pqs_xfer_open_read_confined | ( | const char * | root, |
| const char * | relative ) |
Open a confined transfer file for binary reading.
| root | [const] The configured transfer root directory. |
| relative | [const] The relative transfer path. |
| PQS_EXPORT_API FILE * pqs_xfer_open_write_confined | ( | const char * | root, |
| const char * | relative ) |
Open a confined transfer file for binary writing.
| root | [const] The configured transfer root directory. |
| relative | [const] The relative transfer path. |
| PQS_EXPORT_API bool pqs_xfer_parse_file_metadata | ( | const char * | metadata, |
| char * | relative, | ||
| size_t | relen, | ||
| size_t * | filesize, | ||
| char * | hexhash, | ||
| size_t | hexlen ) |
Parse recursive file-transfer metadata text.
| metadata | [const] The NUL-terminated metadata string. |
| relative | [char] The output relative path buffer. |
| relen | The length of the relative path output buffer. |
| filesize | [size_t] The parsed file size output parameter. |
| hexhash | [char] The output hash text buffer. |
| hexlen | The length of the output hash text buffer. |
| PQS_EXPORT_API bool pqs_xfer_parse_metadata | ( | const char * | metadata, |
| size_t * | filesize, | ||
| char * | hexhash, | ||
| size_t | hexlen ) |
Parse file-transfer metadata text.
| metadata | [const] The NUL-terminated metadata string. |
| filesize | [size_t] The parsed file size output parameter. |
| hexhash | [char] The output hash text buffer. |
| hexlen | The length of the output hash text buffer. |
| PQS_EXPORT_API bool pqs_xfer_path_is_confined | ( | const char * | root, |
| const char * | path, | ||
| bool | existing ) |
Test whether a local path resolves inside the configured root.
| root | [const] The configured root path. |
| path | [const] The path to test. |
| existing | Set to true when the target path must already exist. |
| PQS_EXPORT_API bool pqs_xfer_path_is_safe | ( | const char * | relative | ) |
Test whether a remote file-transfer path is safe.
| relative | [const] The NUL-terminated remote path to test. |
| PQS_EXPORT_API bool pqs_xfer_path_is_symlink | ( | const char * | path | ) |
Test whether a file-system path is a symbolic link or reparse point.
| path | [const] The local file-system path to test. |
| PQS_EXPORT_API size_t pqs_xfer_payload_size | ( | const uint8_t * | message, |
| size_t | msglen ) |
Return the plaintext payload length carried after the PQS application message header.
| message | [const] The application message buffer. |
| msglen | The application message length. |
| PQS_EXPORT_API bool pqs_xfer_publish_temporary_file | ( | const char * | root, |
| const char * | temporary, | ||
| const char * | relative ) |
Publish a staged temporary upload as its final confined file.
| root | [const] The configured transfer root directory. |
| temporary | [const] The relative temporary upload path. |
| relative | [const] The final relative target path. |
| PQS_EXPORT_API bool pqs_xfer_remove_confined | ( | const char * | root, |
| const char * | relative ) |
Remove a confined file inside the configured transfer root.
| root | [const] The configured transfer root directory. |
| relative | [const] The relative transfer path to remove. |
| PQS_EXPORT_API bool pqs_xfer_walk_directory | ( | const char * | localroot, |
| const char * | remoteroot, | ||
| size_t | maxdepth, | ||
| pqs_xfer_walk_callback | callback, | ||
| void * | context ) |
Walk a local directory tree and report PQS transfer paths through a callback.
| localroot | [const] The local root directory to traverse. |
| remoteroot | [const] The relative PQS transfer root associated with localroot. |
| maxdepth | The maximum recursion depth accepted by the traversal. |
| callback | [pqs_xfer_walk_callback] The traversal callback. |
| context | [void] The caller-defined callback context. |