Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 59 lines (46 sloc) 1.373 kb
6b3d19e @bwalex commit basic API test
authored
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <assert.h>
5
6 #include "tcplay_api.h"
7
8 int
9 main(void)
10 {
11 tc_api_opts api_opts;
12 int error;
13
14 error = tc_api_init(/* verbose */1);
15 assert(error == 0);
16
17 memset(&api_opts, 0, sizeof(api_opts));
18 api_opts.tc_device = "/dev/vn1s0";
19 api_opts.tc_passphrase = "apitest2";
20 api_opts.tc_keyfiles = NULL;
21 api_opts.tc_keyfiles_hidden = NULL;
92f96b8 @bwalex make blksz agnostic, fix volume size
authored
22 api_opts.tc_size_hidden_in_bytes = 12000*512;
c4608da @bwalex bugfix, support for different cipher for hidden vol
authored
23 api_opts.tc_passphrase_hidden = "apihidden";
6b3d19e @bwalex commit basic API test
authored
24 api_opts.tc_cipher = "AES-256-XTS,TWOFISH-256-XTS,SERPENT-256-XTS";
c4608da @bwalex bugfix, support for different cipher for hidden vol
authored
25 api_opts.tc_cipher_hidden = "SERPENT-256-XTS,TWOFISH-256-XTS";
6b3d19e @bwalex commit basic API test
authored
26 api_opts.tc_prf_hash = "whirlpool";
c4608da @bwalex bugfix, support for different cipher for hidden vol
authored
27 api_opts.tc_prf_hash_hidden = "RIPEMD160";
6b3d19e @bwalex commit basic API test
authored
28
29 error = tc_api_create_volume(&api_opts);
30 if (error)
31 printf("API ERROR: %s\n", tc_api_get_error_msg());
32 assert(error == 0);
33
34 error = tc_api_uninit();
35 assert(error == 0);
36
37 error = tc_api_init(/*verbose */ 1);
38 assert(error == 0);
39
c4608da @bwalex bugfix, support for different cipher for hidden vol
authored
40 api_opts.tc_passphrase = NULL;
6b3d19e @bwalex commit basic API test
authored
41 api_opts.tc_map_name = "dragonfly-test";
42 api_opts.tc_password_retries = 5;
43 api_opts.tc_interactive_prompt = 1;
46f7fdb @bwalex add prompt timeout support
authored
44 api_opts.tc_prompt_timeout = 5;
6b3d19e @bwalex commit basic API test
authored
45 error = tc_api_map_volume(&api_opts);
46 if (error)
47 printf("API MAP ERROR: %s\n", tc_api_get_error_msg());
48 assert(error == 0);
49
1c225df @bwalex proper support for unmapping
authored
50 system("dmsetup ls");
51 tc_api_unmap_volume(&api_opts);
52
6b3d19e @bwalex commit basic API test
authored
53 error = tc_api_uninit();
54 assert(error == 0);
55
56 return 0;
57 }
58
Something went wrong with that request. Please try again.