2 * Copyright (C) 2013 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 #include "iv_gen_rand.h"
20 typedef struct private_iv_gen_t private_iv_gen_t
;
23 * Private data of an iv_gen_t object.
25 struct private_iv_gen_t
{
28 * Public iv_gen_t interface.
38 METHOD(iv_gen_t
, get_iv
, bool,
39 private_iv_gen_t
*this, u_int64_t seq
, size_t size
, u_int8_t
*buffer
)
45 return this->rng
->get_bytes(this->rng
, size
, buffer
);
48 METHOD(iv_gen_t
, allocate_iv
, bool,
49 private_iv_gen_t
*this, u_int64_t seq
, size_t size
, chunk_t
*chunk
)
55 return this->rng
->allocate_bytes(this->rng
, size
, chunk
);
58 METHOD(iv_gen_t
, destroy
, void,
59 private_iv_gen_t
*this)
61 DESTROY_IF(this->rng
);
65 iv_gen_t
*iv_gen_rand_create()
67 private_iv_gen_t
*this;
72 .allocate_iv
= _allocate_iv
,
75 .rng
= lib
->crypto
->create_rng(lib
->crypto
, RNG_WEAK
),