SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
SharkSslPSAFileStorage.h File Reference

Go to the source code of this file.

Data Structures

struct  SharkSslPSAFileStorage
 Optional encrypted filesystem adapter for Windows and Linux hosts. More...
 

Macros

#define SHARKSSL_PSA_FILE_WRAPPING_KEY_SIZE   32
 
#define SHARKSSL_PSA_FILE_STORAGE_INIT   SharkSslPSAFileStorage()
 

Typedefs

typedef struct SharkSslPSAFileStorage SharkSslPSAFileStorage
 Optional encrypted filesystem adapter for Windows and Linux hosts. More...
 

Functions

psa_status_t SharkSslPSAFileStorage_open (SharkSslPSAFileStorage *o, const char *directory, const uint8_t wrapping_key[SHARKSSL_PSA_FILE_WRAPPING_KEY_SIZE])
 Open or create a private directory, locking it exclusively until close. More...
 
void SharkSslPSAFileStorage_close (SharkSslPSAFileStorage *o)
 Unregister the callback table and quiesce all operations before close. More...
 

Detailed Description

See Choose a SharkSSL API for build scope and the owning API layer.

Macro Definition Documentation

◆ SHARKSSL_PSA_FILE_STORAGE_INIT

#define SHARKSSL_PSA_FILE_STORAGE_INIT   SharkSslPSAFileStorage()

◆ SHARKSSL_PSA_FILE_WRAPPING_KEY_SIZE

#define SHARKSSL_PSA_FILE_WRAPPING_KEY_SIZE   32

Typedef Documentation

◆ SharkSslPSAFileStorage

Optional encrypted filesystem adapter for Windows and Linux hosts.

Initialize with SHARKSSL_PSA_FILE_STORAGE_INIT. The object and its callback table must remain alive while registered. Do not copy an open object. open does not register the table.

Function Documentation

◆ SharkSslPSAFileStorage_close()

void SharkSslPSAFileStorage_close ( SharkSslPSAFileStorage *  o)

Unregister the callback table and quiesce all operations before close.

Destroy volatile keys and purge persistent caches before unregistering. close releases the OS lock and clears the wrapping key. It does not remove stored keys, automatically unregister callbacks, or provide physical erasure.

Parameters
oSharkSslPSAFileStorage *; object to close, or NULL. Unregister and quiesce its callbacks first; a successful open must have matching cleanup.

◆ SharkSslPSAFileStorage_open()

psa_status_t SharkSslPSAFileStorage_open ( SharkSslPSAFileStorage *  o,
const char *  directory,
const uint8_t  wrapping_key[SHARKSSL_PSA_FILE_WRAPPING_KEY_SIZE] 
)

Open or create a private directory, locking it exclusively until close.

directory is UTF-8 on Windows. wrapping_key must contain 32 independently provisioned bytes; retain the same key outside this directory across restarts. The adapter copies and clears its own key on close; it never persists it. Existing directories must belong to the current user and exclude other users. Windows requires a protected owner-only DACL; Linux requires mode 0700. Parent directories must be trusted. Local filesystems are required. AES-256-GCM is required; unsupported targets/configurations return NOT_SUPPORTED. Files are encrypted and authenticated; rollback of an old valid record and physical secure erasure of filesystem copies are outside this adapter. Nonces come from BCryptGenRandom/getrandom. Use a dedicated wrapping key and manage its lifetime externally, including the random-IV GCM invocation limit. Inherited contexts are rejected after fork; reopen in a quiescent process. If rollback I/O fails, the instance refuses further storage callbacks. Repair storage and reconcile the affected ID before resuming after reopen.

Parameters
oSharkSslPSAFileStorage *; required caller-owned object initialized with SHARKSSL_PSA_FILE_STORAGE_INIT, with no open state.
directoryconst char *; required NUL-terminated trusted local directory path. UTF-8 on Windows; an absolute path on Linux. Borrowed for this call.
wrapping_keyconst uint8_t[32]; required separately provisioned AES wrapping key, copied into the adapter. Keep the same key available externally across restarts.
Returns
psa_status_t: PSA_SUCCESS; otherwise an error such as INVALID_ARGUMENT, BAD_STATE, INSUFFICIENT_MEMORY, NOT_PERMITTED, STORAGE_FAILURE, or NOT_SUPPORTED. No callback table is registered by this function.