src/keymanagement.c
branchtest_diphoton
changeset 2166 4c7f95dacc6a
parent 2089 174f5577c0aa
parent 2129 fd3108a623c5
     1.1 --- a/src/keymanagement.c	Fri Oct 06 15:51:35 2017 +0200
     1.2 +++ b/src/keymanagement.c	Tue Oct 17 14:20:12 2017 +0200
     1.3 @@ -736,12 +736,38 @@
     1.4      }
     1.5      else
     1.6      {
     1.7 +        // for undo
     1.8 +        if (session->cached_mistrusted)
     1.9 +            free(session->cached_mistrusted);
    1.10 +        session->cached_mistrusted = identity_dup(ident);
    1.11          status = mark_as_compromized(session, ident->fpr);
    1.12      }
    1.13  
    1.14      return status;
    1.15  }
    1.16  
    1.17 +DYNAMIC_API PEP_STATUS undo_last_mistrust(PEP_SESSION session) {
    1.18 +    assert(session);
    1.19 +    
    1.20 +    if (!session)
    1.21 +        return PEP_ILLEGAL_VALUE;
    1.22 +    
    1.23 +    PEP_STATUS status = PEP_STATUS_OK;
    1.24 +        
    1.25 +    pEp_identity* cached_ident = session->cached_mistrusted;
    1.26 +    
    1.27 +    if (!cached_ident)
    1.28 +        status = PEP_CANNOT_FIND_IDENTITY;
    1.29 +    else {
    1.30 +        status = set_identity(session, cached_ident);            
    1.31 +        free_identity(session->cached_mistrusted);
    1.32 +    }
    1.33 +    
    1.34 +    session->cached_mistrusted = NULL;
    1.35 +
    1.36 +    return status;
    1.37 +}
    1.38 +
    1.39  DYNAMIC_API PEP_STATUS key_reset_trust(
    1.40          PEP_SESSION session,
    1.41          pEp_identity *ident