Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2025 Red Hat |
3 | | * |
4 | | * Author: Daiki Ueno |
5 | | * |
6 | | * This file is part of GnuTLS. |
7 | | * |
8 | | * The GnuTLS is free software; you can redistribute it and/or |
9 | | * modify it under the terms of the GNU Lesser General Public License |
10 | | * as published by the Free Software Foundation; either version 2.1 of |
11 | | * the License, or (at your option) any later version. |
12 | | * |
13 | | * This library is distributed in the hope that it will be useful, but |
14 | | * WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | | * Lesser General Public License for more details. |
17 | | * |
18 | | * You should have received a copy of the GNU Lesser General Public License |
19 | | * along with this program. If not, see <https://www.gnu.org/licenses/> |
20 | | * |
21 | | */ |
22 | | #include "gnutls_int.h" |
23 | | |
24 | | #define CRAU_IMPLEMENTATION 1 |
25 | | #define CRAU_CONTEXT_STACK_DEPTH 8 |
26 | | #include "audit.h" |
27 | | |
28 | | static _Thread_local struct crau_context_stack_st stack; |
29 | | |
30 | | /** |
31 | | * gnutls_audit_push_context: |
32 | | * |
33 | | * Push a new crypto-auditing context to the thread-local context |
34 | | * stack. The call must match the following gnutls_audit_pop_context() |
35 | | * call. This is useful for the applications that define their own |
36 | | * probe points for application level protocols. |
37 | | * |
38 | | * Since: 3.8.11 |
39 | | **/ |
40 | | void gnutls_audit_push_context(long context) |
41 | 0 | { |
42 | 0 | crau_push_context(&stack, context); |
43 | 0 | } |
44 | | |
45 | | /** |
46 | | * gnutls_audit_pop_context: |
47 | | * |
48 | | * Pop the current crypto-auditing context from the thread-local |
49 | | * context stack. This is useful for the applications that define |
50 | | * their own probe points for application level protocols. |
51 | | * |
52 | | * Since: 3.8.11 |
53 | | **/ |
54 | | void gnutls_audit_pop_context(void) |
55 | 0 | { |
56 | 0 | crau_pop_context(&stack); |
57 | 0 | } |
58 | | |
59 | | /** |
60 | | * gnutls_audit_current_context: |
61 | | * |
62 | | * Return the current crypto-auditing context from the thread-local |
63 | | * context stack. This is useful for the applications that define |
64 | | * their own probe points for application level protocols. |
65 | | * |
66 | | * Returns: an opaque context |
67 | | * |
68 | | * Since: 3.8.11 |
69 | | **/ |
70 | | long gnutls_audit_current_context(void) |
71 | 0 | { |
72 | 0 | return crau_current_context(&stack); |
73 | 0 | } |
74 | | |
75 | | void _gnutls_audit_push_context_with_data(long context, ...) |
76 | 0 | { |
77 | 0 | va_list ap; |
78 | |
|
79 | 0 | va_start(ap, context); |
80 | 0 | crau_push_context_with_datav(&stack, context, ap); |
81 | 0 | va_end(ap); |
82 | 0 | } |
83 | | |
84 | | #undef _gnutls_audit_data |
85 | | void _gnutls_audit_data(long unused, ...) |
86 | 0 | { |
87 | 0 | va_list ap; |
88 | |
|
89 | 0 | va_start(ap, unused); |
90 | 0 | crau_datav(&stack, ap); |
91 | | va_end(ap); |
92 | 0 | } |