.\" .\" Copyright (c) 2011 The DragonFly Project. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in .\" the documentation and/or other materials provided with the .\" distribution. .\" 3. Neither the name of The DragonFly Project nor the names of its .\" contributors may be used to endorse or promote products derived .\" from this software without specific, prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .Dd July 5, 2011 .Dt TCPLAY 3 .Os .Sh NAME .Nm tc_api_init , .Nm tc_api_uninit , .Nm tc_api_create_volume , .Nm tc_api_map_volume , .Nm tc_api_unmap_volume , .Nm tc_api_check_cipher , .Nm tc_api_check_prf_hash , .Nm tc_api_get_error_msg , .Nm tc_api_get_summary .Nd TrueCrypt volume management .Sh LIBRARY .Lb libtcplay .Sh SYNOPSIS .In sys/types.h .In tcplay_api.h .Ft int .Fn tc_api_init "int verbose" .Ft int .Fn tc_api_uninit "void" .Ft int .Fn tc_api_create_volume "tc_api_opts *api_opts" .Ft int .Fn tc_api_map_volume "tc_api_opts *api_opts" .Ft int .Fn tc_api_unmap_volume "tc_api_opts *api_opts" .Ft int .Fn tc_api_check_cipher "tc_api_opts *api_opts" .Ft int .Fn tc_api_check_prf_hash "tc_api_opts *api_opts" .Ft const char * .Fn tc_api_get_error_msg "void" .Ft const char * .Fn tc_api_get_summary "void" .Sh DESCRIPTION The .Nm tcplay library provides an interface to create, query and map TrueCrypt-compatible volumes. .Pp The .Fn tc_api_create_volume , .Fn tc_api_map_volume , .Fn tc_api_unmap_volume , .Fn tc_api_check_cipher and .Fn tc_api_check_prf_hash functions take a .Vt tc_api_opts data structure as only argument, which is defined as follows: .Bd -literal typedef struct tc_api_opts { /* Common fields */ char *tc_device; char *tc_passphrase; const char **tc_keyfiles; /* Fields for mapping */ char *tc_map_name; int tc_password_retries; int tc_interactive_prompt; unsigned long tc_prompt_timeout; /* Fields for creation */ char *tc_cipher; char *tc_prf_hash; char *tc_cipher_hidden; char *tc_prf_hash_hidden; size_t tc_size_hidden_in_bytes; char *tc_passphrase_hidden; const char **tc_keyfiles_hidden; } tc_api_opts; .Ed .Pp where the keyfile fields, .Fa tc_keyfiles and .Fa tc_keyfiles_hidden , are .Dv NULL terminated arrays of key file strings. .Pp The .Fn 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 .Fa verbose argument is non-zero, then the library will output information such as errors via stdout and stderr. .Pp The .Fn tc_api_uninit function clears up all internal secure memory, such as memory used for decrypted headers, passphrases, keyfiles, etc. .Pp The .Fn tc_api_create_volume function creates a new volume using the parameters specified in the .Fa api_opts argument. The new volume will be created on the device specified by .Fa tc_device using the cipher specified by .Fa tc_cipher and the pbkdf2 prf hash algorithm specified by .Fa tc_prf_hash and using the passphrase and keyfiles specified by .Fa tc_passphrase and .Fa tc_keyfiles respectively. If .Fa tc_size_hidden_in_bytes is not zero, a hidden volume of the given size will be created, using the cipher specified by .Fa tc_cipher_hidden and the pbkdf2 prf hash algorithm specified by .Fa tc_prf_hash_hidden . If .Fa tc_cipher_hidden or .Fa tc_prf_hash_hidden are .Dv NULL , the same algorithm as for the outer volume will be used. The passphrase and keyfiles used are specified by .Fa tc_passphrase_hidden and .Fa tc_keyfiles_hidden respectively. .Pp The .Fn tc_api_map_volume function maps a volume using the parameters specified in the .Fa api_opts argument. The volume, which will be mapped as .Fa tc_map_name , is specified in .Fa tc_device . The .Fa tc_interactive_prompt field determines whether the user will be prompted to enter a passphrase interactively or whether the passphrase in .Fa tc_passphrase will be used. If an interactive prompt is used, the prompt will time out after .Fa tc_prompt_timeout seconds. A value of 0 indicates that no timeout will occur. The number of passphrase entry retries is defined by .Fa tc_password_retries . Note that the .Fn tc_api_map_volume function does not support accessing an outer volume while protecting the hidden volume. Depending on the passphrase/keyfiles used either the outer or the hidden volume will be mapped. .Pp The .Fn tc_api_unmap_volume unmaps / closes the volume specified in .Fa tc_map_name . .Pp The .Fn tc_api_check_cipher function checks whether the cipher specified in the .Fa api_opts argument field .Fa tc_cipher is valid. .Pp The .Fn tc_api_check_prf_hash function checks whether the prf hash algorithm specified in the .Fa api_opts argument field .Fa tc_prf_hash is valid. .Pp The .Fn tc_api_get_error_msg function should be called whenver another API function returns .Dv TC_ERR . It returns a string containing a description of the error that occurred. .Pp The .Fn tc_api_get_summary function returns a string containing a summary of the current progress of a certain operation. Currently only the volume erasing part of creating a new volume can provide a summary. When no summary is available, an empty string is returned. The output otherwise is equivalent to that of a .Dv SIGINFO signal when using .Xr tcplay 8 . .Sh RETURN VALUES All functions except .Fn tc_api_get_error_msg and .Fn tc_api_get_summary return either .Dv TC_OK to signal that the operation completed successfully, or .Dv TC_ERR to signal that an error occurred. .Pp The .Fn tc_api_get_error_msg and .Fn tc_api_get_summary always return a valid, but possibly empty, string. .Sh COMPATIBILITY The .Nm tcplay library offers full compatibility with TrueCrypt volumes including hidden volumes, system encryption (map-only), keyfiles and cipher cascading. .Sh SEE ALSO .Xr tcplay 8 .Sh HISTORY The .Nm tcplay library appeared in .Dx 2.11 . .Sh AUTHORS .An Alex Hornung