xref: /openbmc/qemu/ui/vnc-auth-sasl.h (revision b6d73e9cb1c620960ca7d864ee0725f8a55fe778)
13e230dd2SCorentin Chary /*
23e230dd2SCorentin Chary  * QEMU VNC display driver: SASL auth protocol
33e230dd2SCorentin Chary  *
43e230dd2SCorentin Chary  * Copyright (C) 2009 Red Hat, Inc
53e230dd2SCorentin Chary  *
63e230dd2SCorentin Chary  * Permission is hereby granted, free of charge, to any person obtaining a copy
73e230dd2SCorentin Chary  * of this software and associated documentation files (the "Software"), to deal
83e230dd2SCorentin Chary  * in the Software without restriction, including without limitation the rights
93e230dd2SCorentin Chary  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
103e230dd2SCorentin Chary  * copies of the Software, and to permit persons to whom the Software is
113e230dd2SCorentin Chary  * furnished to do so, subject to the following conditions:
123e230dd2SCorentin Chary  *
133e230dd2SCorentin Chary  * The above copyright notice and this permission notice shall be included in
143e230dd2SCorentin Chary  * all copies or substantial portions of the Software.
153e230dd2SCorentin Chary  *
163e230dd2SCorentin Chary  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
173e230dd2SCorentin Chary  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
183e230dd2SCorentin Chary  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
193e230dd2SCorentin Chary  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
203e230dd2SCorentin Chary  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
213e230dd2SCorentin Chary  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
223e230dd2SCorentin Chary  * THE SOFTWARE.
233e230dd2SCorentin Chary  */
243e230dd2SCorentin Chary 
252a6a4076SMarkus Armbruster #ifndef QEMU_VNC_AUTH_SASL_H
262a6a4076SMarkus Armbruster #define QEMU_VNC_AUTH_SASL_H
273e230dd2SCorentin Chary 
283e230dd2SCorentin Chary #include <sasl/sasl.h>
293e230dd2SCorentin Chary 
303e230dd2SCorentin Chary typedef struct VncStateSASL VncStateSASL;
313e230dd2SCorentin Chary typedef struct VncDisplaySASL VncDisplaySASL;
323e230dd2SCorentin Chary 
33b76806d4SDaniel P. Berrange #include "authz/base.h"
343e230dd2SCorentin Chary 
353e230dd2SCorentin Chary struct VncStateSASL {
363e230dd2SCorentin Chary     sasl_conn_t *conn;
373e230dd2SCorentin Chary     /* If we want to negotiate an SSF layer with client */
38ee032ca1SStefan Weil     bool wantSSF;
393e230dd2SCorentin Chary     /* If we are now running the SSF layer */
40ee032ca1SStefan Weil     bool runSSF;
413e230dd2SCorentin Chary     /*
423e230dd2SCorentin Chary      * If this is non-zero, then wait for that many bytes
433e230dd2SCorentin Chary      * to be written plain, before switching to SSF encoding
443e230dd2SCorentin Chary      * This allows the VNC auth result to finish being
453e230dd2SCorentin Chary      * written in plain.
463e230dd2SCorentin Chary      */
473e230dd2SCorentin Chary     unsigned int waitWriteSSF;
483e230dd2SCorentin Chary 
493e230dd2SCorentin Chary     /*
503e230dd2SCorentin Chary      * Buffering encoded data to allow more clear data
513e230dd2SCorentin Chary      * to be stuffed onto the output buffer
523e230dd2SCorentin Chary      */
533e230dd2SCorentin Chary     const uint8_t *encoded;
543e230dd2SCorentin Chary     unsigned int encodedLength;
558f61f1c5SDaniel P. Berrange     unsigned int encodedRawLength;
563e230dd2SCorentin Chary     unsigned int encodedOffset;
573e230dd2SCorentin Chary     char *username;
583e230dd2SCorentin Chary     char *mechlist;
593e230dd2SCorentin Chary };
603e230dd2SCorentin Chary 
613e230dd2SCorentin Chary struct VncDisplaySASL {
62b76806d4SDaniel P. Berrange     QAuthZ *authz;
63b76806d4SDaniel P. Berrange     char *authzid;
643e230dd2SCorentin Chary };
653e230dd2SCorentin Chary 
66*b65310abSPaolo Bonzini bool vnc_sasl_server_init(Error **errp);
673e230dd2SCorentin Chary void vnc_sasl_client_cleanup(VncState *vs);
683e230dd2SCorentin Chary 
6930b80fd5SDaniel P. Berrange size_t vnc_client_read_sasl(VncState *vs);
7030b80fd5SDaniel P. Berrange size_t vnc_client_write_sasl(VncState *vs);
713e230dd2SCorentin Chary 
723e230dd2SCorentin Chary void start_auth_sasl(VncState *vs);
733e230dd2SCorentin Chary 
742a6a4076SMarkus Armbruster #endif /* QEMU_VNC_AUTH_SASL_H */
75