sanon: Fix flags and ctx export/import confusion

We were passing SANON flags to _gss_mg_import_rfc4121_context(), which
wants GSS flags.  Meanwhile, I broke gss_inquire_context() on imported
SAnon contexts when I did my review of SAnon.

This commit fixes both issues and removes SANON_FLAG_*, which were only
ever needed because of a flag to track whether a context was locally
initiated or accepted.  Now we use a separate int field of the sanon_ctx
to track whether a context was locally initiated.  Once an SAnon context
is fully established, we rely on gss_inquire_context() on the rfc4121
sub-context for all metadata that isn't the initiator and acceptor names
nor the mechanism OID.
This commit is contained in:
Nicolas Williams
2020-04-26 00:53:29 -05:00
parent 51fdb4bc04
commit 2cb40ed97c
7 changed files with 34 additions and 72 deletions

View File

@@ -43,23 +43,16 @@
#include "mech/mech_locl.h"
/* context is initiator context */
#define SANON_FLAG_INITIATOR 0x0001
/* RFC 4757 extended flags */
#define SANON_FLAG_DCE_STYLE 0x1000
#define SANON_FLAG_IDENTIFY 0x2000
#define SANON_FLAG_EXTENDED_ERROR 0x4000
typedef struct sanon_ctx_desc {
/* X25519 ECDH secret key */
uint8_t sk[crypto_scalarmult_curve25519_BYTES];
/* X25519 ECDH public key */
uint8_t pk[crypto_scalarmult_curve25519_BYTES];
/* SANON_FLAG_xxx */
/* GSS_C_*_FLAG */
uint32_t flags;
/* krb5 context for message protection/PRF */
gss_ctx_id_t rfc4121;
int is_initiator;
} *sanon_ctx;
extern gss_name_t _gss_sanon_anonymous_identity;
@@ -87,34 +80,4 @@ buffer_equal_p(gss_const_buffer_t b1, gss_const_buffer_t b2)
memcmp(b1->value, b2->value, b2->length) == 0;
}
static inline OM_uint32
sanon_to_rfc4757_flags(uint32_t flags)
{
OM_uint32 ret = 0;
if (flags & SANON_FLAG_DCE_STYLE)
ret |= GSS_C_DCE_STYLE;
if (flags & SANON_FLAG_IDENTIFY)
ret |= GSS_C_IDENTIFY_FLAG;
if (flags & SANON_FLAG_EXTENDED_ERROR)
ret |= GSS_C_EXTENDED_ERROR_FLAG;
return ret;
}
static inline uint32_t
rfc4757_to_sanon_flags(OM_uint32 flags)
{
uint32_t ret = 0;
if (flags & GSS_C_DCE_STYLE)
ret |= SANON_FLAG_DCE_STYLE;
if (flags & GSS_C_IDENTIFY_FLAG)
ret |= SANON_FLAG_IDENTIFY;
if (flags & GSS_C_EXTENDED_ERROR_FLAG)
ret |= SANON_FLAG_EXTENDED_ERROR;
return ret;
}
#endif /* SANON_LOCL_H */