2 * Copyright (c) 2019-2020, AuriStor, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * - 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
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE.
33 #define SANON_LOCL_H 1
37 #include <krb5_locl.h> /* for _krb5_SP800_108_HMAC_KDF() */
39 #include <hcrypto/x25519_ref10.h>
42 #include <gkrb5_err.h> /* for GSS_KRB5_S_XXX */
44 #include "mech/mech_locl.h"
46 typedef struct sanon_ctx_desc {
47 /* X25519 ECDH secret key */
48 uint8_t sk[crypto_scalarmult_curve25519_BYTES];
49 /* X25519 ECDH public key */
50 uint8_t pk[crypto_scalarmult_curve25519_BYTES];
51 /* krb5 context for message protection/PRF */
56 extern gss_name_t _gss_sanon_anonymous_identity;
57 extern gss_name_t _gss_sanon_non_anonymous_identity;
59 extern gss_cred_id_t _gss_sanon_anonymous_cred;
60 extern gss_cred_id_t _gss_sanon_non_anonymous_cred;
62 #include "sanon-private.h"
64 #define SANON_WELLKNOWN_USER_NAME "WELLKNOWN/ANONYMOUS@WELLKNOWN:ANONYMOUS"
65 #define SANON_WELLKNOWN_USER_NAME_LEN (sizeof(SANON_WELLKNOWN_USER_NAME) - 1)
67 extern gss_buffer_t _gss_sanon_wellknown_user_name;
69 #define SANON_WELLKNOWN_SERVICE_NAME "WELLKNOWN@ANONYMOUS"
70 #define SANON_WELLKNOWN_SERVICE_NAME_LEN (sizeof(SANON_WELLKNOWN_SERVICE_NAME) - 1)
72 extern gss_buffer_t _gss_sanon_wellknown_service_name;
75 buffer_equal_p(gss_const_buffer_t b1, gss_const_buffer_t b2)
77 return b1->length == b2->length &&
78 memcmp(b1->value, b2->value, b2->length) == 0;
81 /* flags that are valid to be sent from a SAnon initiator in the flags field */
82 #define SANON_PROTOCOL_FLAG_MASK ( GSS_C_DCE_STYLE | GSS_C_IDENTIFY_FLAG | GSS_C_EXTENDED_ERROR_FLAG )
84 #endif /* SANON_LOCL_H */