1 /*
2  * Lasso - A free implementation of the Liberty Alliance specifications.
3  *
4  * Copyright (C) 2004-2011 Entr'ouvert
5  * http://lasso.entrouvert.org
6  *
7  * Authors: See AUTHORS file in top-level directory.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef __LASSO_KEY_H__
24 #define __LASSO_KEY_H__
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif /* __cplusplus */
29 
30 #include "xml/xml.h"
31 
32 #define LASSO_TYPE_KEY (lasso_key_get_type())
33 #define LASSO_KEY(obj) \
34 	(G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_KEY, \
35 				LassoKey))
36 #define LASSO_KEY_CLASS(klass) \
37 	(G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_KEY, \
38 				LassoKeyClass))
39 #define LASSO_IS_KEY(obj) \
40 	(G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_KEY))
41 #define LASSO_IS_KEY_CLASS(klass) \
42 	(G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_KEY))
43 #define LASSO_KEY_GET_CLASS(o) \
44 	(G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_KEY, \
45 				LassoKeyClass))
46 
47 typedef struct _LassoKey LassoKey;
48 typedef struct _LassoKeyClass LassoKeyClass;
49 typedef struct _LassoKeyPrivate LassoKeyPrivate;
50 
51 typedef enum _LassoKeyType {
52 	LASSO_KEY_TYPE_FOR_SIGNATURE,
53 } LassoKeyType;
54 
55 struct _LassoKey {
56 	LassoNode parent;
57 	/*< private >*/
58 	LassoKeyPrivate *private_data;
59 };
60 
61 struct _LassoKeyClass {
62 	LassoNodeClass parent;
63 };
64 
65 LASSO_EXPORT GType lasso_key_get_type();
66 
67 LASSO_EXPORT LassoKey* lasso_key_new_for_signature_from_memory(const void *buffer, size_t size,
68 		char *password, LassoSignatureMethod signature_method, char *certificate);
69 
70 LASSO_EXPORT LassoKey* lasso_key_new_for_signature_from_base64_string(char *base64_string,
71 		char *password, LassoSignatureMethod signature_method, char *certificate);
72 
73 LASSO_EXPORT LassoKey* lasso_key_new_for_signature_from_file(char *filename_or_buffer,
74 		char *password, LassoSignatureMethod signature_method, char *certificate);
75 
76 LASSO_EXPORT lasso_error_t lasso_key_query_verify(LassoKey* key, const char *query);
77 
78 LASSO_EXPORT char* lasso_key_query_sign(LassoKey *key, const char *query);
79 
80 LASSO_EXPORT lasso_error_t lasso_key_saml2_xml_verify(LassoKey *key, char *id, xmlNode *document);
81 
82 LASSO_EXPORT xmlNode *lasso_key_saml2_xml_sign(LassoKey *key, const char *id, xmlNode *document);
83 
84 #ifdef __cplusplus
85 }
86 #endif /* __cplusplus */
87 
88 #endif /* __LASSO_KEY_H__ */
89