printed plugin names have a hyphen
[strongswan.git] / src / libstrongswan / plugins / af_alg / af_alg_ops.h
1 /*
2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
4 *
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>.
9 *
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
13 * for more details.
14 */
15
16 /**
17 * @defgroup af_alg_ops af_alg_ops
18 * @{ @ingroup af_alg
19 */
20
21 #ifndef AF_ALG_OPS_H_
22 #define AF_ALG_OPS_H_
23
24 #include <library.h>
25
26 #include <linux/if_alg.h>
27
28 #ifndef AF_ALG
29 #define AF_ALG 38
30 #endif /* AF_ALG */
31
32 #ifndef SOL_ALG
33 #define SOL_ALG 279
34 #endif /* SOL_ALG */
35
36 extern const char *af_alg_plugin_name;
37
38 typedef struct af_alg_ops_t af_alg_ops_t;
39
40 /**
41 * Helper to run AF_ALG operations.
42 */
43 struct af_alg_ops_t {
44
45 /**
46 * Hash a chunk of data.
47 *
48 * @param data data to hash
49 * @param out buffer to write hash to, NULL for append mode
50 * @param outlen number of bytes to read into out
51 */
52 void (*hash)(af_alg_ops_t *this, chunk_t data, char *out, size_t outlen);
53
54 /**
55 * Reset hasher state.
56 */
57 void (*reset)(af_alg_ops_t *this);
58
59 /**
60 * En-/Decrypt a chunk of data.
61 *
62 * @param type crypto operation (ALG_OP_DECRYPT/ALG_OP_ENCRYPT)
63 * @param iv iv to use
64 * @param data data to encrypt/decrypt
65 * @param out buffer write processed data to
66 */
67 void (*crypt)(af_alg_ops_t *this, u_int32_t type, chunk_t iv, chunk_t data,
68 char *out);
69
70 /**
71 * Set the key for en-/decryption or HMAC/XCBC operations.
72 *
73 * @param key key to set for transform
74 */
75 void (*set_key)(af_alg_ops_t *this, chunk_t key);
76
77 /**
78 * Destroy a af_alg_ops_t.
79 */
80 void (*destroy)(af_alg_ops_t *this);
81 };
82
83 /**
84 * Create a af_alg_ops instance.
85 *
86 * @param type algorithm type (hash, skcipher)
87 * @param alg algorithm name
88 * @return TRUE if AF_ALG socket bound successfully
89 */
90 af_alg_ops_t *af_alg_ops_create(char *type, char *alg);
91
92 #endif /** AF_ALG_OPS_H_ @}*/