/src/opensc/openpace/src/ca_lib.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2010-2012 Frank Morgner and Dominik Oepen |
3 | | * |
4 | | * This file is part of OpenPACE. |
5 | | * |
6 | | * OpenPACE is free software: you can redistribute it and/or modify it under |
7 | | * the terms of the GNU General Public License as published by the Free |
8 | | * Software Foundation, either version 3 of the License, or (at your option) |
9 | | * any later version. |
10 | | * |
11 | | * OpenPACE is distributed in the hope that it will be useful, but WITHOUT ANY |
12 | | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
13 | | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
14 | | * details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License along with |
17 | | * OpenPACE. If not, see <http://www.gnu.org/licenses/>. |
18 | | * |
19 | | * Additional permission under GNU GPL version 3 section 7 |
20 | | * |
21 | | * If you modify this Program, or any covered work, by linking or combining it |
22 | | * with OpenSSL (or a modified version of that library), containing |
23 | | * parts covered by the terms of OpenSSL's license, the licensors of |
24 | | * this Program grant you additional permission to convey the resulting work. |
25 | | * Corresponding Source for a non-source form of such a combination shall include |
26 | | * the source code for the parts of OpenSSL used as well as that of the |
27 | | * covered work. |
28 | | * |
29 | | * If you modify this Program, or any covered work, by linking or combining it |
30 | | * with OpenSC (or a modified version of that library), containing |
31 | | * parts covered by the terms of OpenSC's license, the licensors of |
32 | | * this Program grant you additional permission to convey the resulting work. |
33 | | * Corresponding Source for a non-source form of such a combination shall include |
34 | | * the source code for the parts of OpenSC used as well as that of the |
35 | | * covered work. |
36 | | */ |
37 | | |
38 | | /** |
39 | | * @file |
40 | | * |
41 | | * @author Frank Morgner <frankmorgner@gmail.com> |
42 | | * @author Dominik Oepen <oepen@informatik.hu-berlin.de> |
43 | | */ |
44 | | |
45 | | #ifdef HAVE_CONFIG_H |
46 | | #include "config.h" |
47 | | #endif |
48 | | |
49 | | #include "eac_err.h" |
50 | | #include "eac_lib.h" |
51 | | #include "ssl_compat.h" |
52 | | |
53 | | CA_CTX * |
54 | | CA_CTX_new(void) |
55 | 0 | { |
56 | 0 | CA_CTX *ctx = OPENSSL_zalloc(sizeof(CA_CTX)); |
57 | 0 | if (!ctx) |
58 | 0 | return NULL; |
59 | | |
60 | 0 | ctx->ka_ctx = KA_CTX_new(); |
61 | 0 | if (!ctx->ka_ctx) { |
62 | 0 | OPENSSL_free(ctx); |
63 | 0 | return NULL; |
64 | 0 | } |
65 | 0 | ctx->lookup_csca_cert = EAC_get_default_csca_lookup(); |
66 | |
|
67 | 0 | return ctx; |
68 | 0 | } |
69 | | |
70 | | void |
71 | | CA_CTX_clear_free(CA_CTX *ctx) |
72 | 0 | { |
73 | 0 | if (ctx) { |
74 | 0 | KA_CTX_clear_free(ctx->ka_ctx); |
75 | 0 | OPENSSL_free(ctx); |
76 | 0 | } |
77 | 0 | } |
78 | | |
79 | | int |
80 | | CA_CTX_set_protocol(CA_CTX * ctx, int protocol) |
81 | 0 | { |
82 | 0 | if (!ctx) { |
83 | 0 | log_err("Invalid arguments"); |
84 | 0 | return 0; |
85 | 0 | } |
86 | | |
87 | 0 | if (!KA_CTX_set_protocol(ctx->ka_ctx, protocol)) |
88 | 0 | return 0; |
89 | | |
90 | 0 | ctx->protocol = protocol; |
91 | |
|
92 | 0 | return 1; |
93 | 0 | } |