TCPLAY(3) | Library Functions Manual | TCPLAY(3) |
tc_api_init
,
tc_api_uninit
, tc_api_has
,
tc_api_cipher_iterate
,
tc_api_prf_iterate
,
tc_api_task_init
,
tc_api_task_uninit
,
tc_api_task_set
,
tc_api_task_do
,
tc_api_task_info_get
,
tc_api_task_get_error
—
TrueCrypt volume management
TrueCrypt-compatible API library (libtcplay, -ltcplay)
#include
<tcplay_api.h>
typedef int
(*tc_api_cipher_iterator_fn)
(void
*priv, const char
*name, int
key_length_in_bits, int
ciphers_in_chain);
typedef int
(*tc_api_prf_iterator_fn)
(void
*priv, const char
*name);
typedef int
(*tc_api_state_change_fn)
(void
*priv, const char
*state, int
enter_state);
int
tc_api_init
(int
verbose);
int
tc_api_uninit
(void);
int
tc_api_has
(const
char *feature);
int
tc_api_cipher_iterate
(tc_api_cipher_iterator_fn
fn, void
*priv);
int
tc_api_prf_iterate
(tc_api_prf_iterator_fn
fn, void
*priv);
tc_api_task
tc_api_task_init
(const
char *op);
int
tc_api_task_uninit
(tc_api_task
task);
int
tc_api_task_set
(tc_api_task
task, const char
*key, ...);
int
tc_api_task_do
(tc_api_task
task);
int
tc_api_task_info_get
(tc_api_task
task, const char
*key, ...);
const char *
tc_api_task_get_error
(tc_api_task
task);
The tcplay
library provides an interface
to create, query, map and manage TrueCrypt-compatible volumes.
The
tc_api_init
()
function initializes the library internals and prepares it for use via the
API. This function has to be called before using any other API function. If
the verbose argument is non-zero, then the library
will output information such as errors via stdout and stderr.
The
tc_api_uninit
()
function clears up all internal secure memory, such as memory used for
decrypted headers, passphrases, keyfiles, etc.
The
tc_api_has
()
function checks whether the loaded tcplay library has the feature specified
by the feature argument. The current version of the
tcplay
library supports the following features:
Feature | Description |
trim |
Allows enabling discards/TRIM when mapping a volume |
The
tc_api_cipher_iterate
()
function passes every available cipher chain to the callback provided in the
fn argument. The priv argument
is passed on every call of the callback function. The name of the cipher
chain is passed to the callback function in the name
argument. Similarly, the ciphers_in_chain argument
holds the number of ciphers in the current chain, and
key_length_in_bits holds the total key length for the
cipher chain, in bits.
The
tc_api_prf_iterate
()
function passes every available cipher chain to the callback provided in the
fn argument. The priv argument
is passed on every call of the callback function. The name of the PKBDF2 PRF
algorithm is passed to the callback function in the
name argument.
The
tc_api_task_init
()
function initializes and returns a tc_api_task opaque
pointer that can be used to run tcplay
commands.
Each task can be used only for a single
tc_api_task_do
() call, and must be deallocated using
tc_api_task_uninit
().
The op argument can be one of the following:
The
tc_api_task_set
()
function allows setting a number of different options for the current task.
The following table shows which keys are available on calls to
tc_api_task_set
() for each of the operations. The
letter M
indicates the setting is mandatory, whilst
* indicates the
setting is optional.
Key | create | info | map | unmap | info_mapped | modify | restore |
dev |
M | M | M | * | M | M | |
map_name |
M | M | M | ||||
interactive |
* | * | * | * | * | ||
retries |
* | * | * | * | * | ||
timeout |
* | * | * | ||||
state_change_fn |
* | * | * | ||||
weak_keys_and_salt |
* | * | * | ||||
secure_erase |
* | ||||||
prf_algo |
* | ||||||
h_prf_algo |
* | ||||||
cipher_chain |
* | ||||||
h_cipher_chain |
* | ||||||
fde |
* | * | |||||
sys |
* | * | ? | ? | |||
use_backup_header |
* | * | * | * | |||
header_from_file |
* | * | * | * | |||
allow_trim |
* | ||||||
save_header_to_file |
* | ||||||
passphrase |
* | * | * | * | * | ||
h_passphrase |
* | * | * | * | * | ||
keyfiles |
* | * | * | * | * | ||
h_keyfiles |
* | * | * | * | * | ||
new_passphrase |
* | ||||||
new_keyfiles |
* | ||||||
new_prf_algo |
* |
tc_api_task_set
() function
depend on the key being set.
tc_api_task_set
().tcplay
cipher chain. It determines which
cipher chain is used to encrypt the outer volume.tcplay
cipher chain. It determines which
cipher chain is used to encrypt the hidden volume.NULL
the volume will implicitly be treated as a
non-system encrypted volume.NULL
it forces tcplay
to
use the header in the specified file instead of the regular outer volume
header.NULL
it forces tcplay
to
use the header in the specified file instead of the regular hidden volume
header.NULL
it forces tcplay
to
write the (modified) header to the specified file instead of replacing the
volume headers.tcplay
uses to access the
volume.tcplay
uses to unlock the hidden
volume header. This option is only used if a hidden volume is being
created or the protect_hidden setting is set.
Otherwise tcplay
will first use the regular
passphrase to try to unlock the outer volume and then try to unlock the
hidden volume header with the same passphrase without ever using
h_passphrase.NULL
the given keyfile will be added to the
keyfile pool. Multiple calls to set this option with a non-
NULL
argument result add additional keyfiles. If
NULL
all keyfiles are cleared.NULL
the given keyfile will be added to the
keyfile pool. Multiple calls to set this option with a non-
NULL
argument result add additional keyfiles. If
NULL
all keyfiles are cleared. This option is only
used if a hidden volume is being created or the
protect_hidden setting is set. Otherwise
tcplay
will first use the regular keyfiles to try
to unlock the outer volume and then try to unlock the hidden volume header
with the same keyfiles without ever using
h_keyfiles.NULL
the given keyfile will be added to the new
keyfile pool. Multiple calls to set this option with a non-
NULL
argument result add additional keyfiles. If
NULL
all new keyfiles are cleared. When the volume
header is modified, it will be reencrypted using the new keyfiles.tcplay
is starting or stopping the
time-intensive sub-task specified in the state
argument.The
tc_api_task_do
()
function runs the task specified in the task argument.
Before running the task, tc_api_task_do
() performs a
simple sanity check of the arguments set previously using
tc_api_task_set
() before performing the actual
operation. After a call to tc_api_task_do
() for the
info or info_mapped operations, the
queried information is available to be accessed using
tc_api_task_info_get
().
The
tc_api_task_info_get
()
function can be used to query the result of a info or
info_mapped operation. The task
argument is the task used in a previous
tc_api_task_do
() call. The key
argument can be one of the following:
Key | type | Description |
device |
char * | Corresponding device node |
cipher |
char * | Used cipher chain |
prf |
char * | Used PBKDF2 PRF algorithm |
key_bits |
int * | Number of key bits |
size |
int64_t * | Volume size in bytes |
iv_offset |
int64_t * | IV Offset of volume in bytes |
block_offset |
int64_t * | Block Offset of volume in bytes |
The second vararg argument must be of the type specified in the above table. The first vararg argument is always the size of the storage provided in the second argument. For a char * argument, the size corresponds to the size of the buffer at the provided location and must be of type size_t. For an int * or int64_t * argument, it should be the size of the underlying type.
The
tc_api_task_get_error
()
function can be used to get a detailed error message after a failed
tc_api_task_do call. The task
argument is the task used in a previous
tc_api_task_do
() call.
TrueCrypt limits passphrases to 64 characters (including the
terminating null character). To be compatible with it,
tcplay
does the same. All passphrases (exlcuding
keyfiles) are trimmed to 64 characters. Similarly, keyfiles are limited to a
size of 1 MB, but up to 256 keyfiles can be used.
All functions except tc_api_task_init
()
and tc_api_task_get_error
() return either
TC_OK
to indicate that the operation completed
successfully, or TC_ERR_UNIMPL
to indicate that the
operation is not implemented , or TC_ERR
to indicate
that any other error occurred.
The tc_api_task_get_error
() function
always return a valid, but possibly empty (or irrelevant, if not called
after an error occurred) string.
The tc_api_task_init
() function returns
NULL
if an error occurred and an opaque
tc_api_task otherwise.
The tcplay
library offers full
compatibility with TrueCrypt volumes including hidden volumes, system
encryption (map-only), keyfiles and cipher cascading.
The tcplay
library appeared in
DragonFly 2.11.
Alex Hornung
January 20, 2014 | Debian |