xref: /freebsd/crypto/krb5/src/plugins/preauth/otp/otp_state.h (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* plugins/preauth/otp/otp_state.h - Internal declarations for OTP module */
3 /*
4  * Copyright 2013 Red Hat, Inc.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  *    1. Redistributions of source code must retain the above copyright
10  *       notice, this list of conditions and the following disclaimer.
11  *
12  *    2. Redistributions in binary form must reproduce the above copyright
13  *       notice, this list of conditions and the following disclaimer in
14  *       the documentation and/or other materials provided with the
15  *       distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef OTP_H_
31 #define OTP_H_
32 
33 #include <k5-int.h>
34 #include <verto.h>
35 
36 #include <com_err.h>
37 
38 typedef enum otp_response {
39     otp_response_fail = 0,
40     otp_response_success
41     /* Other values reserved for responses like next token or new pin. */
42 } otp_response;
43 
44 typedef struct otp_state_st otp_state;
45 typedef void
46 (*otp_cb)(void *data, krb5_error_code retval, otp_response response,
47           char *const *indicators);
48 
49 krb5_error_code
50 otp_state_new(krb5_context ctx, otp_state **self);
51 
52 void
53 otp_state_free(otp_state *self);
54 
55 void
56 otp_state_verify(otp_state *state, verto_ctx *ctx, krb5_const_principal princ,
57                  const char *config, const krb5_pa_otp_req *request,
58                  otp_cb cb, void *data);
59 
60 #endif /* OTP_H_ */
61