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

Forward transport errors from Secure Session callbacks #375

Merged
merged 5 commits into from
Feb 12, 2019

Commits on Feb 11, 2019

  1. Add TransportError to themis::Error

    We will need to return TransportErrors from Secure Session methods on
    failures to extend the ErrorKind enumeration to actually contain the
    transport error inside its ErrorKind::SessionTransportError variant.
    
    This change has a number of implications. First of all, TransportError
    is not copyable. Therefore we have to let go of the Clone and Copy
    implementations on the ErrorKind as well as the Clone impl on Error.
    One should not usually copy errors anyway so this should be okay.
    Note that Error::kind() now returns a reference to the stored error
    kind instead of its copy.
    
    Another important thing is that TransportError does not implement
    PartialEq as it is not possible to compare abstract errors in any
    meaningful way. This implies that we cannot automatically derive
    implementation of PartialEq for ErrorKind. We have to implement it
    manually. We need to compare *kinds* of errors here so it is okay
    to simply ignore the details of transport errors and treat them
    as equivalent.
    ilammy committed Feb 11, 2019
    Configuration menu
    Copy the full SHA
    ab6cbda View commit details
    Browse the repository at this point in the history
  2. Forward transport errors from Secure Session callbacks

    Now that we are able to store TransportError inside of a themis::Error
    we can actually forward the error from the callback to the method call.
    With this the user can actually see why the transport layer has failed.
    
    Use the provided SecureSessionContext to temporarily store the error
    while the control is still in the C code. Then we extract the error
    and return it.
    
    Such implementation does not support concurrent usage of Secure Session
    from multiple threads but it's not thread-safe anyway so it is fine to
    use this approach.
    
    We can use negative return values to indicate implementation-specific
    errors in Secure Session callbacks. The C code returns them as is for
    us to inspect. While we're here, stop using bare constant "-1" and give
    it a name. Also, handle the overflow with a different error kind.
    ilammy committed Feb 11, 2019
    Configuration menu
    Copy the full SHA
    96429a0 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9a2b889 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    d1a6720 View commit details
    Browse the repository at this point in the history

Commits on Feb 12, 2019

  1. Forward errors during channel negotiation

    There's another secure_session_receive() call here in this method. It
    too can return special error codes.
    ilammy committed Feb 12, 2019
    Configuration menu
    Copy the full SHA
    5118683 View commit details
    Browse the repository at this point in the history