updated Doxyfile
[strongswan.git] / src / libstrongswan / credentials / keys / private_key.h
1 /*
2 * Copyright (C) 2007 Martin Willi
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 * $Id$
16 */
17
18 /**
19 * @defgroup private_key private_key
20 * @{ @ingroup keys
21 */
22
23 #ifndef PRIVATE_KEY_H_
24 #define PRIVATE_KEY_H_
25
26 typedef struct private_key_t private_key_t;
27
28 #include <utils/identification.h>
29 #include <credentials/keys/public_key.h>
30
31 /**
32 * Abstract private key interface.
33 */
34 struct private_key_t {
35
36 /**
37 * Get the key type.
38 *
39 * @return type of the key
40 */
41 key_type_t (*get_type)(private_key_t *this);
42
43 /**
44 * Create a signature over a chunk of data.
45 *
46 * @param scheme signature scheme to use
47 * @param data chunk of data to sign
48 * @param signature where to allocate created signature
49 * @return TRUE if signature created
50 */
51 bool (*sign)(private_key_t *this, signature_scheme_t scheme,
52 chunk_t data, chunk_t *signature);
53 /**
54 * Decrypt a chunk of data.
55 *
56 * @param crypto chunk containing encrypted data
57 * @param plain where to allocate decrypted data
58 * @return TRUE if data decrypted and plaintext allocated
59 */
60 bool (*decrypt)(private_key_t *this, chunk_t crypto, chunk_t *plain);
61
62 /**
63 * Get the strength of the key in bytes.
64 *
65 * @return strength of the key in bytes
66 */
67 size_t (*get_keysize) (private_key_t *this);
68
69 /**
70 * Get a unique key identifier, such as a hash over the public key.
71 *
72 * @param type type of the key ID to get
73 * @return unique ID of the key as identification_t, or NULL
74 */
75 identification_t* (*get_id) (private_key_t *this, id_type_t type);
76
77 /**
78 * Get the public part from the private key.
79 *
80 * @return public key
81 */
82 public_key_t* (*get_public_key)(private_key_t *this);
83
84 /**
85 * Check if a private key belongs to a public key.
86 *
87 * @param public public key
88 * @return TRUE, if keys belong together
89 */
90 bool (*belongs_to) (private_key_t *this, public_key_t *public);
91
92 /**
93 * Get an encoded form of the private key.
94 *
95 * @todo Do we need a encoding type specification?
96 *
97 * @return allocated chunk containing encoded private key
98 */
99 chunk_t (*get_encoding)(private_key_t *this);
100
101 /**
102 * Increase the refcount to this private key.
103 *
104 * @return this, with an increased refcount
105 */
106 private_key_t* (*get_ref)(private_key_t *this);
107
108 /**
109 * Decrease refcount, destroy private_key if no more references.
110 */
111 void (*destroy)(private_key_t *this);
112 };
113
114 #endif /** PRIVATE_KEY_H_ @}*/