Initialize TKM client library in tkm.c
[strongswan.git] / src / charon-tkm / src / tkm / tkm_nonceg.c
1 /*
2 * Copyrigth (C) 2012 Reto Buerki
3 * Copyright (C) 2012 Adrian-Ken Rueegsegger
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 #include "tkm_nonceg.h"
18
19 typedef struct private_tkm_nonceg_t private_tkm_nonceg_t;
20
21 /**
22 * Private data of a tkm_nonceg_t object.
23 */
24 struct private_tkm_nonceg_t {
25
26 /**
27 * Public tkm_nonceg_t interface.
28 */
29 tkm_nonceg_t public;
30
31 };
32
33 METHOD(nonce_gen_t, get_nonce, bool,
34 private_tkm_nonceg_t *this, size_t size, u_int8_t *buffer)
35 {
36 // TODO: Request nonce from TKM and fill it into buffer.
37 return TRUE;
38 }
39
40 METHOD(nonce_gen_t, allocate_nonce, bool,
41 private_tkm_nonceg_t *this, size_t size, chunk_t *chunk)
42 {
43 *chunk = chunk_alloc(size);
44 return get_nonce(this, chunk->len, chunk->ptr);
45 }
46
47 METHOD(nonce_gen_t, destroy, void,
48 private_tkm_nonceg_t *this)
49 {
50 free(this);
51 }
52
53 /*
54 * Described in header.
55 */
56 tkm_nonceg_t *tkm_nonceg_create()
57 {
58 private_tkm_nonceg_t *this;
59
60 INIT(this,
61 .public = {
62 .nonce_gen = {
63 .get_nonce = _get_nonce,
64 .allocate_nonce = _allocate_nonce,
65 .destroy = _destroy,
66 },
67 },
68 );
69
70 return &this->public;
71 }