Mercurial > trustbridge
annotate common/certhelp.h @ 895:8ac2d9b0668d
Add sleep in installer on update
This fixes a race between shutdown of trustbridge and the
installer trustbridge executable replacement.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 08 Aug 2014 15:10:48 +0200 |
parents | 17e1c8f37d72 |
children | 3cd8dd706aaa |
rev | line source |
---|---|
404 | 1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=2) | |
5 * and comes with ABSOLUTELY NO WARRANTY! | |
6 * See LICENSE.txt for details. | |
7 */ | |
259
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
8 #ifndef CERTHELP_H |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
9 #define CERTHELP_H |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
10 |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
11 /* Polarssl mh.h contains a conversion which gcc warns about */ |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
12 #pragma GCC diagnostic ignored "-Wsign-conversion" |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
13 #pragma GCC diagnostic ignored "-Wconversion" |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
14 #include <polarssl/oid.h> |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
15 #include <polarssl/x509_crt.h> |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
16 #pragma GCC diagnostic pop |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
17 #pragma GCC diagnostic pop |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
18 |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
19 #define CERT_OID_CN (unsigned char *)OID_AT_CN "\0" |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
20 #define CERT_OID_O (unsigned char *)OID_AT_ORGANIZATION "\0" |
337
2207e94a0cc3
Add some more oid's for data and enable c++ linkage
Andre Heinecke <aheinecke@intevation.de>
parents:
259
diff
changeset
|
21 #define CERT_OID_OU (unsigned char *)OID_AT_ORG_UNIT "\0" |
2207e94a0cc3
Add some more oid's for data and enable c++ linkage
Andre Heinecke <aheinecke@intevation.de>
parents:
259
diff
changeset
|
22 #define CERT_OID_SN (unsigned char *)OID_AT_SERIAL_NUMBER "\0" |
2207e94a0cc3
Add some more oid's for data and enable c++ linkage
Andre Heinecke <aheinecke@intevation.de>
parents:
259
diff
changeset
|
23 #ifdef __cplusplus |
2207e94a0cc3
Add some more oid's for data and enable c++ linkage
Andre Heinecke <aheinecke@intevation.de>
parents:
259
diff
changeset
|
24 extern "C" { |
2207e94a0cc3
Add some more oid's for data and enable c++ linkage
Andre Heinecke <aheinecke@intevation.de>
parents:
259
diff
changeset
|
25 #endif |
259
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
26 |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
27 /** |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
28 * @file |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
29 * @brief Helper functinos to handle and parse X.509 certificates. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
30 * |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
31 * Simple helper functions based on PolarSSL. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
32 */ |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
33 |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
34 /** |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
35 * @brief Extracts value of an gieb OID from an x509_name object. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
36 * |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
37 * The value is copyed to an bull byte terminated c-string. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
38 * The caller should free it after use. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
39 * @param[in] namebuf ponter to the x509_name object. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
40 * @param[in] oid the oid to search for. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
41 * @returns the extracted String, or NULL in failure. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
42 */ |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
43 char *get_oid_valstr(x509_name *namebuf, unsigned char *oid); |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
44 |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
45 /** |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
46 * @brief Parse x509 certificate and retrieve specified OID from Subject. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
47 * |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
48 * The value is copyed to an bull byte terminated c-string. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
49 * The caller should free it after use. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
50 * @param[in] derdata pointer to certificate in DER format. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
51 * @param[in] derlen length of the DER data. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
52 * @param[in] oid the OID to search for. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
53 * @returns the extracted String, or NULL in failure. |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
54 */ |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
55 char *x509_parse_subject(unsigned char *derdata, size_t derlen, |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
56 unsigned char *oid); |
337
2207e94a0cc3
Add some more oid's for data and enable c++ linkage
Andre Heinecke <aheinecke@intevation.de>
parents:
259
diff
changeset
|
57 #ifdef __cplusplus |
2207e94a0cc3
Add some more oid's for data and enable c++ linkage
Andre Heinecke <aheinecke@intevation.de>
parents:
259
diff
changeset
|
58 } |
2207e94a0cc3
Add some more oid's for data and enable c++ linkage
Andre Heinecke <aheinecke@intevation.de>
parents:
259
diff
changeset
|
59 #endif |
259
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
60 |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
61 #endif |