Move PKCS#12 key derivation to a separate file
[strongswan.git] / src / libstrongswan / credentials / containers / pkcs12.h
1 /*
2 * Copyright (C) 2013 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
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 pkcs12 pkcs12
18 * @{ @ingroup containers
19 */
20
21 #ifndef PKCS12_H_
22 #define PKCS12_H_
23
24 #include <crypto/hashers/hasher.h>
25
26 typedef enum pkcs12_key_type_t pkcs12_key_type_t;
27
28 /**
29 * The types of password based keys used by PKCS#12.
30 */
31 enum pkcs12_key_type_t {
32 PKCS12_KEY_ENCRYPTION = 1,
33 PKCS12_KEY_IV = 2,
34 PKCS12_KEY_MAC = 3,
35 };
36
37 /**
38 * Derive the keys used in PKCS#12 for password integrity/privacy mode.
39 *
40 * @param hash hash algorithm to use for key derivation
41 * @param password password (ASCII)
42 * @param salt salt value
43 * @param iterations number of iterations
44 * @param type type of key to derive
45 * @param key the returned key, must be allocated of desired length
46 * @return TRUE on success
47 */
48 bool pkcs12_derive_key(hash_algorithm_t hash, chunk_t password, chunk_t salt,
49 u_int64_t iterations, pkcs12_key_type_t type, chunk_t key);
50
51 #endif /** PKCS12_H_ @}*/