Files
Kovid Goyal 8f0b7eff31 Encrypt sessions saved at logout with a key in the macOS Keychain
Every snapshot is encrypted with AES-256-GCM using a random key, stored
in the login keychain under a random id. The name of every file is
authenticated, so files cannot be swapped. The key is deleted before the
snapshot whenever it is removed, so copies of the snapshot left on disk
or in backups cannot be read.

The keychain is never allowed to show any UI. If storing the key fails
nothing is saved, if reading it fails the snapshot is deleted, with the
error logged in both cases.

The key is generated, stored and read only in C, in mlocked memory that
is cleared when freed, via a new random_secret() and the Keychain
functions in cocoa_window.m.
2026-10-16 11:57:31 +05:30

15 lines
455 B
C

/*
* Copyright (C) 2026 Kovid Goyal <kovid at kovidgoyal.net>
*
* Distributed under terms of the GPL3 license.
*/
#pragma once
#include "data-types.h"
// Create a Secret object containing a copy of data
PyObject *secret_from_data(const void *data, size_t len);
// Get the data of a Secret object, without copying it. Sets a Python exception and returns false if obj is not a Secret.
bool secret_data(PyObject *obj, const void **data, size_t *len);