1 /* audit.h - Definitions for the audit subsystem
2 * Copyright (C) 2007 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * GnuPG is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * GnuPG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef GNUPG_COMMON_AUDIT_H
21 #define GNUPG_COMMON_AUDIT_H
28 typedef struct audit_ctx_s
*audit_ctx_t
;
30 /* Constants for the audit type. */
33 AUDIT_TYPE_NONE
= 0, /* No type set. */
34 AUDIT_TYPE_ENCRYPT
, /* Data encryption. */
35 AUDIT_TYPE_SIGN
, /* Signature creation. */
36 AUDIT_TYPE_DECRYPT
, /* Data decryption. */
37 AUDIT_TYPE_VERIFY
/* Signature verification. */
41 /* The events we support. */
45 /* No such event. Its value shall be 0 and no other values shall
46 be assigned to the other enum symbols. This is required so
47 that the exaudit.awk script comes up with correct values
48 without running cc. */
51 /* All preparations done so that the actual processing can start
52 now. This indicates that all parameters are okay and we can
53 start to process the actual data. */
55 AUDIT_AGENT_READY
, /* err */
56 /* Indicates whether the gpg-agent is available. For some
57 operations the agent is not required and thus no such event
60 AUDIT_DIRMNGR_READY
, /* err */
61 /* Indicates whether the Dirmngr is available. For some
62 operations the Dirmngr is not required and thus no such event
65 AUDIT_GPG_READY
, /* err */
66 /* Indicates whether the Gpg engine is available. */
68 AUDIT_GPGSM_READY
, /* err */
69 /* Indicates whether the Gpgsm engine is available. */
71 AUDIT_G13_READY
, /* err */
72 /* Indicates whether the G13 engine is available. */
75 /* Data to be processed has been seen. */
77 AUDIT_DETACHED_SIGNATURE
,
78 /* The signature is a detached one. */
81 /* A certifciate only signature has been detected. */
83 AUDIT_DATA_HASH_ALGO
, /* int */
84 /* The hash algo given as argument is used for this signature.
85 This event will be repeated for all hash algorithms used with
88 AUDIT_BAD_DATA_HASH_ALGO
, /* string */
89 /* The hash algo as specified by the signature can't be used.
90 STRING is the description of this algorithm which usually is an
91 OID string. STRING may be NULL. */
93 AUDIT_DATA_HASHING
, /* ok_err */
94 /* Logs the result of the data hashing. */
96 AUDIT_READ_ERROR
, /* ok_err */
97 /* A generic read error occurred. */
99 AUDIT_WRITE_ERROR
, /* ok_err */
100 /* A generic write error occurred. */
103 /* The program was used in an inappropriate way; For example by
104 passing a data object while the signature does not expect one
107 AUDIT_SAVE_CERT
, /* cert, ok_err */
108 /* Save the certificate received in a message. */
110 AUDIT_NEW_SIG
, /* int */
111 /* Start the verification of a new signature for the last data
112 object. The argument is the signature number as used
113 internally by the program. */
115 AUDIT_SIG_NAME
, /* string */
116 /* The name of a signer. This is the name or other identification
117 data as known from the signature and not the name from the
118 certificate used for verification. An example for STRING when
119 using CMS is: "#1234/CN=Prostetnic Vogon Jeltz". */
121 AUDIT_SIG_STATUS
, /* string */
122 /* The signature status of the current signer. This is the last
123 audit information for one signature. STRING gives the status:
125 "error" - there was a problem checking this or any signature.
126 "unsupported" - the signature type is not supported.
127 "no-cert" - The certificate of the signer was not found (the
128 S/N+issuer of the signer is already in the log).
129 "bad" - bad signature
130 "good" - good signature
133 AUDIT_VALIDATE_CHAIN
,
134 /* Start the validation of a certificate chain. */
137 AUDIT_CHAIN_CERT
, /* cert */
138 AUDIT_CHAIN_ROOTCERT
,/* cert */
140 /* These 4 events are used to log the certificates making up a
141 certificate chain. ROOTCERT is used for the trustanchor and
142 CERT for all other certificates. */
144 AUDIT_CHAIN_STATUS
, /* err */
145 /* Tells the final status of the chain validation. */
147 AUDIT_ROOT_TRUSTED
, /* cert, err */
148 /* Tells whether the root certificate is trusted. This event is
149 emmited durcing chain validation. */
151 AUDIT_CRL_CHECK
, /* err */
152 /* Tells the status of a CRL or OCSP check. */
154 AUDIT_GOT_RECIPIENTS
, /* int */
155 /* Records the number of recipients to be used for encryption.
156 This includes the recipients set by --encrypt-to but records 0
157 if no real recipient has been given. */
159 AUDIT_SESSION_KEY
, /* string */
160 /* Mark the creation or availibility of the session key. The
161 parameter is the algorithm ID. */
163 AUDIT_ENCRYPTED_TO
, /* cert, err */
164 /* Records the certificate used for encryption and whether the
165 session key could be encrypted to it (err==0). */
167 AUDIT_ENCRYPTION_DONE
,
168 /* Encryption succeeded. */
173 AUDIT_LAST_EVENT
/* Marker for parsing this list. */
178 audit_ctx_t
audit_new (void);
179 void audit_release (audit_ctx_t ctx
);
180 void audit_set_type (audit_ctx_t ctx
, audit_type_t type
);
181 void audit_log (audit_ctx_t ctx
, audit_event_t event
);
182 void audit_log_ok (audit_ctx_t ctx
, audit_event_t event
, gpg_error_t err
);
183 void audit_log_i (audit_ctx_t ctx
, audit_event_t event
, int value
);
184 void audit_log_s (audit_ctx_t ctx
, audit_event_t event
, const char *value
);
185 void audit_log_cert (audit_ctx_t ctx
, audit_event_t event
,
186 ksba_cert_t cert
, gpg_error_t err
);
188 void audit_print_result (audit_ctx_t ctx
, estream_t stream
, int use_html
);
192 #endif /*GNUPG_COMMON_AUDIT_H*/