★ wanayoo — archive 1999 https://github.com/pythongssapi/python-gssapi/pull/123Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Channel Binding Extension #123

Open
wants to merge 2 commits into
base: master
from

Conversation

@cipherboy
Copy link
Contributor

@cipherboy cipherboy commented Jul 18, 2017

This PR implements channel bindings per this draft RFC, and depends on this PR: krb5/krb5#668. In the mean time, patches can be found in this branch.

New raw calls:

  • create_sec_context
  • set_context_flags

High level changes:

  • SecurityContext constructor takes a ret_flags parameter
  • channel_bindings support -> create_sec_context called
  • channel_bindings support + ret_flags or req_flags set -> set_context_flags called
@cipherboy cipherboy force-pushed the cipherboy:channel_bindings branch 4 times, most recently from e0737b4 to 005aaf8 Jul 18, 2017
Args:
context (SecurityContext): Context to set flags on
req_flags (uint64_t): Request flags for init/accept_sec_context()

This comment has been minimized.

@DirectXMan12

DirectXMan12 Aug 10, 2017
Member

this should be a IntEnumFlagSet like the other flag types (see the main raw SecContext code)

Args:
context (SecurityContext): Context to set flags on
req_flags (uint64_t): Request flags for init/accept_sec_context()
ret_flags_understood: Return flags that are understood by the

This comment has been minimized.

@DirectXMan12

DirectXMan12 Aug 10, 2017
Member

is this an output parameter? It's not clear what this does. python-gssapi doc should be more-or-less understandable without prior knowledge (it should mostly be usable as GSSAPI documentation).

This comment has been minimized.

@cipherboy

cipherboy Aug 11, 2017
Author Contributor

ret_flags_understood is a set of return flags that are understood by the calling application.

In other word, it is a subset of possible ret_flag values from gss_init/accept_sec_context; the only useful ret_flag_understood parameter to set would be the channel bound flag; setting or not setting any other flag does not change the behavior. (This last point about not changing behavior is the subject of a revision in the draft, as if you set req_flags = GSS_C_MUTUAL_FLAG but set ret_flags_understood = 0, gss_init/accept_sec_context will still give a ret_flag with GSS_C_MUTUAL_FLAG on success).

ret_flags was what the original draft called it in the C bindings, hence the discrepancy in the high level API. Suggestions welcome about a more helpful name.

def __init__(self, base=None, token=None,
name=None, creds=None, lifetime=None, flags=None,
def __init__(self, base=None, token=None, name=None, creds=None,
lifetime=None, flags=None, ret_flags=None,

This comment has been minimized.

@DirectXMan12

DirectXMan12 Aug 10, 2017
Member

this parameter name is not the best...

@@ -104,6 +111,17 @@ def __init__(self, base=None, token=None,
"argument when creating an accepting "
"security context")

if rchannel_bindings is not None:
empty_ctx = rchannel_bindings.create_sec_context()
self.copy_from(empty_ctx)

This comment has been minimized.

@DirectXMan12

DirectXMan12 Aug 10, 2017
Member

do this in __new__ so you don't have to call copy_from.

application
Returns:
bool: Success

This comment has been minimized.

@DirectXMan12

DirectXMan12 Aug 10, 2017
Member

it's fine not to return anything. This doesn't actually return bool: success because it never returns False.

bool: Success
Raises:
GSSError

This comment has been minimized.

@DirectXMan12

DirectXMan12 Aug 10, 2017
Member

Is there a specific error code for in-process sec contexts? It should be documented if there is.

This comment has been minimized.

@cipherboy

cipherboy Aug 11, 2017
Author Contributor

The only error that is possible are GSS_S_FAILURE, when context.raw_ctx is none/missing for some reason or when context.raw_ctx is malformed. See here.

(This is because context is stored in a gss_union_ctx_id_t until gss_init/accept_sec_context, as no mech is known when gss_set_context_flags is called).

cipherboy added 2 commits Jul 25, 2017
This adds support for the channel binding extension
from the Kitten WG. This adds two new calls to the
raw api: create_sec_context and set_context_flags,
allowing ret_flags_understood to be set for mechs
that support it. This flag is exposed as the
channel_bound requirement flag.

Signed-off-by: Alexander Scheel <ascheel@redhat.com>
This is in support of the Kitten WG channel
binding draft. A new field is added to the
SecurityContext constructor, ret_flags, allowing
the new raw methods to be automatically used
from the high-level API when either req_flags
or ret_flags are specified.

Signed-off-by: Alexander Scheel <ascheel@redhat.com>
@cipherboy cipherboy force-pushed the cipherboy:channel_bindings branch from 005aaf8 to e941d82 Aug 11, 2017
@cipherboy
Copy link
Contributor Author

@cipherboy cipherboy commented Aug 11, 2017

Okie dokie, this has been updated with comments. Thanks @DirectXMan12! :)

Please see the comments on some of your changes as well.

raise GSSError(maj_stat, min_stat)


def set_context_flags(SecurityContext context, uint64_t req_flags,

This comment has been minimized.

@DirectXMan12

DirectXMan12 Sep 5, 2017
Member

don't type the flags here (since they can be IntEnumFlagSets), and they should either be not None if non-optional, or =None if optional (then use or like in https://github.com/pythongssapi/python-gssapi/blob/master/gssapi/raw/sec_contexts.pyx#L179)

@@ -107,6 +107,10 @@ cdef class SecurityContext:

self.raw_ctx = NULL

def copy_from(self, SecurityContext other):

This comment has been minimized.

@DirectXMan12

DirectXMan12 Sep 5, 2017
Member

this isn't used

def __init__(self, base=None, token=None,
name=None, creds=None, lifetime=None, flags=None,
def __init__(self, base=None, token=None, name=None, creds=None,
lifetime=None, flags=None, ret_flags_understood=None,

This comment has been minimized.

@DirectXMan12

DirectXMan12 Sep 5, 2017
Member

we probably should avoid changing argument order (since this isn't python 3, we can't do keyword-only args).

@@ -104,6 +113,14 @@ def __init__(self, base=None, token=None,
"argument when creating an accepting "
"security context")

if rchannel_bindings is not None:
i_flags = int(self._desired_flags)
i_ret_flags = int(self._understood_flags)

This comment has been minimized.

@DirectXMan12

DirectXMan12 Sep 5, 2017
Member

shouldn't need a manual cast here -- the low-level code should handle it.

if not init_cont_needed:
break

if ((int(init_ret_flags) & m_init_ret_flags) != e_init_ret_flags):

This comment has been minimized.

@DirectXMan12

DirectXMan12 Sep 5, 2017
Member

shouldn't need a cast to int here -- IntEnumFlagSet handles that case -- that's why we have it ;-).

[0, f_both, f_cb, f_cb, cb, cb, f_cb, 0, f_cb, f_cb],
]

for test in tests:

This comment has been minimized.

@DirectXMan12

DirectXMan12 Sep 5, 2017
Member

use parameterized?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.