]> git.ipfire.org Git - thirdparty/strongswan.git/blame - src/libstrongswan/crypto/iv/iv_gen.h
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libstrongswan / crypto / iv / iv_gen.h
CommitLineData
403057aa
TB
1/*
2 * Copyright (C) 2013 Tobias Brunner
19ef2aec
TB
3 *
4 * Copyright (C) secunet Security Networks AG
403057aa
TB
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/**
18 * @defgroup iv iv
19 * @{ @ingroup crypto
20 */
21
22#ifndef IV_GEN_H_
23#define IV_GEN_H_
24
25typedef struct iv_gen_t iv_gen_t;
26
27#include <library.h>
28
29/**
30 * Generic interface for initialization vector (IV) generators.
31 */
32struct iv_gen_t {
33
34 /**
35 * Generates an IV and writes it into the buffer.
36 *
e8229ad5 37 * @param seq external sequence number
403057aa
TB
38 * @param size size of IV in bytes
39 * @param buffer pointer where the generated IV will be written
40 * @return TRUE if IV allocation was successful, FALSE otherwise
41 */
b12c53ce
AS
42 bool (*get_iv)(iv_gen_t *this, uint64_t seq, size_t size,
43 uint8_t *buffer) __attribute__((warn_unused_result));
403057aa
TB
44
45 /**
46 * Generates an IV and allocates space for it.
47 *
e8229ad5 48 * @param seq external sequence number
403057aa
TB
49 * @param size size of IV in bytes
50 * @param chunk chunk which will hold the generated IV
51 * @return TRUE if IV allocation was successful, FALSE otherwise
52 */
b12c53ce 53 bool (*allocate_iv)(iv_gen_t *this, uint64_t seq, size_t size,
403057aa
TB
54 chunk_t *chunk) __attribute__((warn_unused_result));
55
56 /**
57 * Destroys an IV generator object.
58 */
59 void (*destroy)(iv_gen_t *this);
60};
61
a4549e55
MW
62/**
63 * Select an IV generator for a given encryption algorithm.
64 *
65 * @param alg encryption algorithm
66 * @return IV generator
67 */
68iv_gen_t* iv_gen_create_for_alg(encryption_algorithm_t alg);
69
403057aa 70#endif /** IV_GEN_H_ @}*/