Path: blob/main/crypto/krb5/src/include/k5-spake.h
34889 views
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */1/* include/k5-spake.h - SPAKE preauth mech declarations */2/*3* Copyright (C) 2015 by the Massachusetts Institute of Technology.4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9*10* * Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12*13* * Redistributions in binary form must reproduce the above copyright14* notice, this list of conditions and the following disclaimer in15* the documentation and/or other materials provided with the16* distribution.17*18* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS19* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT20* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS21* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE22* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,23* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES24* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR25* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)26* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,27* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED29* OF THE POSSIBILITY OF SUCH DAMAGE.30*/3132/*33* The SPAKE preauth mechanism allows long-term client keys to be used for34* preauthentication without exposing them to offline dictionary attacks. The35* negotiated key can also be used for second-factor authentication. This36* header file declares structures and encoder/decoder functions for the37* mechanism's padata messages.38*/3940#ifndef K5_SPAKE_H41#define K5_SPAKE_H4243#include "k5-int.h"4445/* SPAKESecondFactor is contained within a SPAKEChallenge, SPAKEResponse, or46* EncryptedData message and contains a second-factor challenge or response. */47typedef struct krb5_spake_factor_st {48int32_t type;49krb5_data *data;50} krb5_spake_factor;5152/* SPAKESupport is sent from the client to the KDC to indicate which group the53* client supports. */54typedef struct krb5_spake_support_st {55int32_t ngroups;56int32_t *groups;57} krb5_spake_support;5859/* SPAKEChallenge is sent from the KDC to the client to communicate its group60* selection, public value, and second-factor challenge options. */61typedef struct krb5_spake_challenge_st {62int32_t group;63krb5_data pubkey;64krb5_spake_factor **factors;65} krb5_spake_challenge;6667/* SPAKEResponse is sent from the client to the KDC to communicate its public68* value and encrypted second-factor response. */69typedef struct krb5_spake_response_st {70krb5_data pubkey;71krb5_enc_data factor;72} krb5_spake_response;7374enum krb5_spake_msgtype {75SPAKE_MSGTYPE_UNKNOWN = -1,76SPAKE_MSGTYPE_SUPPORT = 0,77SPAKE_MSGTYPE_CHALLENGE = 1,78SPAKE_MSGTYPE_RESPONSE = 2,79SPAKE_MSGTYPE_ENCDATA = 380};8182/* PA-SPAKE is a choice among the message types which can appear in a PA-SPAKE83* padata element. */84typedef struct krb5_pa_spake_st {85enum krb5_spake_msgtype choice;86union krb5_spake_message_choices {87krb5_spake_support support;88krb5_spake_challenge challenge;89krb5_spake_response response;90krb5_enc_data encdata;91} u;92} krb5_pa_spake;9394krb5_error_code encode_krb5_spake_factor(const krb5_spake_factor *val,95krb5_data **code_out);96krb5_error_code decode_krb5_spake_factor(const krb5_data *code,97krb5_spake_factor **val_out);98void k5_free_spake_factor(krb5_context context, krb5_spake_factor *val);99100krb5_error_code encode_krb5_pa_spake(const krb5_pa_spake *val,101krb5_data **code_out);102krb5_error_code decode_krb5_pa_spake(const krb5_data *code,103krb5_pa_spake **val_out);104void k5_free_pa_spake(krb5_context context, krb5_pa_spake *val);105106#endif /* K5_SPAKE_H */107108109