1 /*
2  * XML Security Library (http://www.aleksey.com/xmlsec).
3  *
4  * This is free software; see Copyright file in the source
5  * distribution for preciese wording.
6  *
7  * Copyright (C) 2002-2016 Aleksey Sanin <aleksey@aleksey.com>. All Rights Reserved.
8  */
9 #ifndef __XMLSEC_OPENSSL_APP_H__
10 #define __XMLSEC_OPENSSL_APP_H__
11 
12 #include <openssl/pem.h>
13 #include <openssl/bio.h>
14 
15 #include <xmlsec/xmlsec.h>
16 #include <xmlsec/keys.h>
17 #include <xmlsec/keysmngr.h>
18 #include <xmlsec/transforms.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif /* __cplusplus */
23 
24 /********************************************************************
25  *
26  * Init/shutdown
27  *
28  ********************************************************************/
29 XMLSEC_CRYPTO_EXPORT int                xmlSecOpenSSLAppInit            (const char* config);
30 XMLSEC_CRYPTO_EXPORT int                xmlSecOpenSSLAppShutdown        (void);
31 
32 /********************************************************************
33  *
34  * Keys Manager
35  *
36  *******************************************************************/
37 XMLSEC_CRYPTO_EXPORT int                xmlSecOpenSSLAppDefaultKeysMngrInit(xmlSecKeysMngrPtr mngr);
38 XMLSEC_CRYPTO_EXPORT int                xmlSecOpenSSLAppDefaultKeysMngrAdoptKey(xmlSecKeysMngrPtr mngr,
39                                                                          xmlSecKeyPtr key);
40 XMLSEC_CRYPTO_EXPORT int                xmlSecOpenSSLAppDefaultKeysMngrLoad(xmlSecKeysMngrPtr mngr,
41                                                                          const char* uri);
42 XMLSEC_CRYPTO_EXPORT int                xmlSecOpenSSLAppDefaultKeysMngrSave(xmlSecKeysMngrPtr mngr,
43                                                                          const char* filename,
44                                                                          xmlSecKeyDataType type);
45 #ifndef XMLSEC_NO_X509
46 XMLSEC_CRYPTO_EXPORT int                xmlSecOpenSSLAppKeysMngrCertLoad(xmlSecKeysMngrPtr mngr,
47                                                                          const char *filename,
48                                                                          xmlSecKeyDataFormat format,
49                                                                          xmlSecKeyDataType type);
50 XMLSEC_CRYPTO_EXPORT int                xmlSecOpenSSLAppKeysMngrCertLoadMemory(xmlSecKeysMngrPtr mngr,
51                                                                          const xmlSecByte* data,
52                                                                          xmlSecSize dataSize,
53                                                                          xmlSecKeyDataFormat format,
54                                                                          xmlSecKeyDataType type);
55 XMLSEC_CRYPTO_EXPORT int                xmlSecOpenSSLAppKeysMngrCertLoadBIO(xmlSecKeysMngrPtr mngr,
56                                                                          BIO* bio,
57                                                                          xmlSecKeyDataFormat format,
58                                                                          xmlSecKeyDataType type);
59 
60 XMLSEC_CRYPTO_EXPORT int                xmlSecOpenSSLAppKeysMngrAddCertsPath(xmlSecKeysMngrPtr mngr,
61                                                                          const char *path);
62 XMLSEC_CRYPTO_EXPORT int                xmlSecOpenSSLAppKeysMngrAddCertsFile(xmlSecKeysMngrPtr mngr,
63                                                                          const char *filename);
64 
65 #endif /* XMLSEC_NO_X509 */
66 
67 
68 /********************************************************************
69  *
70  * Keys
71  *
72  ********************************************************************/
73 XMLSEC_CRYPTO_EXPORT xmlSecKeyPtr       xmlSecOpenSSLAppKeyLoad         (const char *filename,
74                                                                          xmlSecKeyDataFormat format,
75                                                                          const char *pwd,
76                                                                          void* pwdCallback,
77                                                                          void* pwdCallbackCtx);
78 XMLSEC_CRYPTO_EXPORT xmlSecKeyPtr       xmlSecOpenSSLAppKeyLoadMemory   (const xmlSecByte* data,
79                                                                          xmlSecSize dataSize,
80                                                                          xmlSecKeyDataFormat format,
81                                                                          const char *pwd,
82                                                                          void* pwdCallback,
83                                                                          void* pwdCallbackCtx);
84 XMLSEC_CRYPTO_EXPORT xmlSecKeyPtr       xmlSecOpenSSLAppKeyLoadBIO      (BIO* bio,
85                                                                          xmlSecKeyDataFormat format,
86                                                                          const char *pwd,
87                                                                          void* pwdCallback,
88                                                                          void* pwdCallbackCtx);
89 
90 #ifndef XMLSEC_NO_X509
91 XMLSEC_CRYPTO_EXPORT xmlSecKeyPtr       xmlSecOpenSSLAppPkcs12Load      (const char* filename,
92                                                                          const char* pwd,
93                                                                          void* pwdCallback,
94                                                                          void* pwdCallbackCtx);
95 XMLSEC_CRYPTO_EXPORT xmlSecKeyPtr       xmlSecOpenSSLAppPkcs12LoadMemory(const xmlSecByte* data,
96                                                                          xmlSecSize dataSize,
97                                                                          const char* pwd,
98                                                                          void* pwdCallback,
99                                                                          void* pwdCallbackCtx);
100 XMLSEC_CRYPTO_EXPORT xmlSecKeyPtr       xmlSecOpenSSLAppPkcs12LoadBIO   (BIO* bio,
101                                                                          const char* pwd,
102                                                                          void* pwdCallback,
103                                                                          void* pwdCallbackCtx);
104 
105 XMLSEC_CRYPTO_EXPORT int                xmlSecOpenSSLAppKeyCertLoad     (xmlSecKeyPtr key,
106                                                                          const char* filename,
107                                                                          xmlSecKeyDataFormat format);
108 XMLSEC_CRYPTO_EXPORT int                xmlSecOpenSSLAppKeyCertLoadMemory(xmlSecKeyPtr key,
109                                                                          const xmlSecByte* data,
110                                                                          xmlSecSize dataSize,
111                                                                          xmlSecKeyDataFormat format);
112 XMLSEC_CRYPTO_EXPORT int                xmlSecOpenSSLAppKeyCertLoadBIO  (xmlSecKeyPtr key,
113                                                                          BIO* bio,
114                                                                          xmlSecKeyDataFormat format);
115 XMLSEC_CRYPTO_EXPORT xmlSecKeyPtr       xmlSecOpenSSLAppKeyFromCertLoadBIO(BIO* bio,
116                                                                          xmlSecKeyDataFormat format);
117 #endif /* XMLSEC_NO_X509 */
118 
119 XMLSEC_CRYPTO_EXPORT void*              xmlSecOpenSSLAppGetDefaultPwdCallback(void);
120 
121 
122 #ifdef __cplusplus
123 }
124 #endif /* __cplusplus */
125 
126 #endif /* __XMLSEC_OPENSSL_APP_H__ */
127 
128 
129