Annotation of embedaddon/strongswan/src/libpttls/sasl/sasl_mechanism.h, revision 1.1
1.1 ! misho 1: /*
! 2: * Copyright (C) 2013 Martin Willi
! 3: * Copyright (C) 2013 revosec AG
! 4: *
! 5: * This program is free software; you can redistribute it and/or modify it
! 6: * under the terms of the GNU General Public License as published by the
! 7: * Free Software Foundation; either version 2 of the License, or (at your
! 8: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
! 9: *
! 10: * This program is distributed in the hope that it will be useful, but
! 11: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! 12: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
! 13: * for more details.
! 14: */
! 15:
! 16: /**
! 17: * @defgroup sasl sasl
! 18: * @ingroup pt_tls
! 19: *
! 20: * @defgroup sasl_mechanism sasl_mechanism
! 21: * @{ @ingroup sasl
! 22: */
! 23:
! 24: #ifndef SASL_MECHANISM_H_
! 25: #define SASL_MECHANISM_H_
! 26:
! 27: typedef struct sasl_mechanism_t sasl_mechanism_t;
! 28:
! 29: #include <library.h>
! 30:
! 31: /**
! 32: * Constructor function for SASL mechanism.
! 33: *
! 34: * @param name name of the requested SASL mechanism
! 35: * @param client client identity, NULL to act as server
! 36: * @return SASL mechanism, NULL on failure
! 37: */
! 38: typedef sasl_mechanism_t*(*sasl_mechanism_constructor_t)(char *name,
! 39: identification_t *client);
! 40:
! 41: /**
! 42: * Generic interface for SASL mechanisms.
! 43: */
! 44: struct sasl_mechanism_t {
! 45:
! 46: /**
! 47: * Get the name of this SASL mechanism.
! 48: *
! 49: * @return name of SASL mechanism
! 50: */
! 51: char* (*get_name)(sasl_mechanism_t *this);
! 52:
! 53: /**
! 54: * Get the client identity
! 55: *
! 56: * @return client identity
! 57: */
! 58: identification_t* (*get_client)(sasl_mechanism_t *this);
! 59:
! 60: /**
! 61: * Build a SASL message to send to remote host.
! 62: *
! 63: * A message is returned if the return value is NEED_MORE or SUCCESS. A
! 64: * client MUST NOT return SUCCESS in build(), as the final message
! 65: * is always from server to client (even if it is an empty result message).
! 66: *
! 67: * @param message receives allocated SASL message, to free
! 68: * @return
! 69: * - FAILED if mechanism failed
! 70: * - NEED_MORE if additional exchanges required
! 71: * - INVALID_STATE if currently nothing to build
! 72: * - SUCCESS if mechanism authenticated successfully
! 73: */
! 74: status_t (*build)(sasl_mechanism_t *this, chunk_t *message);
! 75:
! 76: /**
! 77: * Process a SASL message received from remote host.
! 78: *
! 79: * If a server returns SUCCESS during process(), an empty result message
! 80: * is sent to complete the SASL exchange.
! 81: *
! 82: * @param message received SASL message to process
! 83: * @return
! 84: * - FAILED if mechanism failed
! 85: * - NEED_MORE if additional exchanges required
! 86: * - SUCCESS if mechanism authenticated successfully
! 87: */
! 88: status_t (*process)(sasl_mechanism_t *this, chunk_t message);
! 89:
! 90: /**
! 91: * Destroy a sasl_mechanism_t.
! 92: */
! 93: void (*destroy)(sasl_mechanism_t *this);
! 94: };
! 95:
! 96: /**
! 97: * Create a sasl_mechanism instance.
! 98: *
! 99: * @param name name of SASL mechanism to create
! 100: * @param client client identity, NULL to act as server
! 101: * @return SASL mechanism instance, NULL if not found
! 102: */
! 103: sasl_mechanism_t *sasl_mechanism_create(char *name, identification_t *client);
! 104:
! 105: /**
! 106: * Create an enumerator over supported SASL mechanism names.
! 107: *
! 108: * @param server TRUE for server instance, FALSE for client
! 109: * @return enumerator over char*
! 110: */
! 111: enumerator_t* sasl_mechanism_create_enumerator(bool server);
! 112:
! 113: #endif /** SASL_MECHANISM_H_ @}*/
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>