sync/cond_act_sync.yml2
author buff <andreas@pep-project.org>
Fri, 28 Jun 2019 18:16:23 +0200
branchIOS-1576
changeset 3892 e7e371c1ad53
parent 3856 8a23d954fd74
child 3971 8b2d20579b85
permissions -rw-r--r--
IOS-1576 increases timeout, 60 does not work involving UI
vb@2831
     1
// This file is under GNU General Public License 3.0
vb@2831
     2
// see LICENSE.txt
vb@2831
     3
vb@2831
     4
// generate conditions and actions
vb@2831
     5
vb@3512
     6
// Copyleft (c) 2017-2019, p≡p foundation
vb@2831
     7
vb@2831
     8
// Written by Volker Birk
vb@2831
     9
vb@2831
    10
vb@2844
    11
include ./sql_func.yml2
vb@2831
    12
vb@2831
    13
// condition: PEP_STATUS «@name»(PEP_SESSION session, bool *result)
vb@2831
    14
vb@2831
    15
condition deviceGrouped {
vb@2831
    16
    call "exec_sql_int" with "sql"
vb@3525
    17
        > "select count(*) from identity where is_own = 1 and (flags & 0x100) = 0x100;"
vb@2831
    18
    |> *result = _result > 0;
vb@2831
    19
}
vb@2831
    20
vb@3825
    21
condition weAreOfferer
vb@2902
    22
||
vb@3773
    23
    TID_t *t1 = &session->sync_state.keysync.challenge;
vb@3772
    24
    TID_t *t2 = &session->sync_state.own.challenge;
vb@2902
    25
vb@2905
    26
    *result = _TID_greater(t1, t2);
vb@2902
    27
||
vb@2902
    28
vb@2831
    29
condition partnerIsGrouped
vb@3773
    30
|> *result = session->sync_state.keysync.is_group;
vb@2831
    31
vb@3514
    32
condition sameChallenge
vb@3514
    33
||
vb@3773
    34
    TID_t *t1 = &session->sync_state.keysync.challenge;
vb@3772
    35
    TID_t *t2 = &session->sync_state.own.challenge;
vb@3514
    36
vb@3514
    37
    *result = t1->size == t2->size && memcmp(t1->buf, t2->buf, t1->size) == 0;
vb@3514
    38
||
vb@3514
    39
vb@3779
    40
condition sameNegotiation
vb@3510
    41
||
vb@3773
    42
    TID_t *t1 = &session->sync_state.keysync.negotiation;
vb@3779
    43
    TID_t *t2 = &session->sync_state.comm_partner.negotiation;
vb@3510
    44
vb@3591
    45
    // test if TID is identical
vb@3510
    46
    *result = t1->size == t2->size && memcmp(t1->buf, t2->buf, t1->size) == 0;
vb@3510
    47
||
vb@3510
    48
vb@3779
    49
condition sameNegotiationAndPartner
vb@3591
    50
||
vb@3773
    51
    TID_t *t1 = &session->sync_state.keysync.negotiation;
vb@3779
    52
    TID_t *t2 = &session->sync_state.comm_partner.negotiation;
vb@3591
    53
vb@3779
    54
    const char *s1 = session->sync_state.comm_partner.sender_fpr;
vb@3779
    55
    const char *s2 = session->sync_state.transport.sender_fpr;
vb@3591
    56
vb@3591
    57
    // test if TID is identical
vb@3591
    58
    *result = t1->size == t2->size && memcmp(t1->buf, t2->buf, t1->size) == 0
vb@3591
    59
    // and test if we're talking to the same sender
vb@3591
    60
            && s1 && s2 && strcmp(s1, s2) == 0;
vb@3591
    61
||
vb@3591
    62
vb@2831
    63
condition keyElectionWon
vb@2831
    64
||
vb@3779
    65
    pEp_identity *from = session->sync_state.transport.from;
vb@3779
    66
    char *sender_fpr = session->sync_state.comm_partner.sender_fpr;
vb@2831
    67
vb@3389
    68
    assert(from && from->address && from->address[0] && from->user_id &&
vb@3389
    69
            from->user_id[0]);
vb@3389
    70
    if (!(from && from->address && from->address[0] && from->user_id &&
vb@3389
    71
            from->user_id[0]))
vb@2831
    72
        return PEP_ILLEGAL_VALUE;
vb@2831
    73
vb@2831
    74
    pEp_identity *me = NULL;
vb@2901
    75
    PEP_STATUS status = get_identity(session, from->address, from->user_id, &me);
vb@2831
    76
    assert(status == PEP_STATUS_OK);
vb@2831
    77
    if (status)
vb@2831
    78
        return status;
vb@2831
    79
vb@2831
    80
    assert(me->fpr && me->fpr[0]);
vb@2831
    81
    if (!(me->fpr && me->fpr[0])) {
vb@2831
    82
        free_identity(me);
vb@2831
    83
        return PEP_ILLEGAL_VALUE;
vb@2831
    84
    }
vb@2831
    85
vb@3779
    86
    size_t len = MIN(strlen(sender_fpr), strlen(me->fpr));
vb@3779
    87
    *result = strncasecmp(sender_fpr, me->fpr, len) > 0;
vb@2831
    88
    free_identity(me);
vb@2831
    89
||
vb@2831
    90
vb@2831
    91
// action: PEP_STATUS «@name»(PEP_SESSION session)
vb@2831
    92
vb@2831
    93
function "new_UUID" {
vb@2831
    94
    param "dst";
vb@2831
    95
    ||
vb@3781
    96
        {
vb@3781
    97
            pEpUUID c;
vb@3781
    98
            uuid_generate_random(c);
vb@2831
    99
vb@3781
   100
            OCTET_STRING_fromBuf(«$dst», (char *) c, 16);
vb@3781
   101
        }
vb@2831
   102
    ||
vb@2831
   103
}
vb@2831
   104
vb@2831
   105
function "copy_UUID" {
vb@2831
   106
    param "src", param "dst";
vb@2831
   107
    ||
vb@3605
   108
        {
vb@3605
   109
            TID_t *src = «$src»;
vb@3605
   110
            TID_t *dst = «$dst»;
vb@2831
   111
vb@3605
   112
            assert(src->size == 16);
vb@3605
   113
            if (!(src->size == 16))
vb@3605
   114
                return PEP_UNKNOWN_ERROR;
vb@2831
   115
vb@3605
   116
            OCTET_STRING_fromBuf(dst, (char *) src->buf, src->size);
vb@3605
   117
        }
vb@3605
   118
    ||
vb@3605
   119
}
vb@3605
   120
vb@3605
   121
function "xor_UUID" {
vb@3605
   122
    param "src", param "dst";
vb@3605
   123
    ||
vb@3605
   124
        {
vb@3605
   125
            TID_t *src = «$src»;
vb@3605
   126
            TID_t *dst = «$dst»;
vb@3605
   127
vb@3605
   128
            assert(src->size == 16 && dst->size == 16);
vb@3605
   129
            if (!(src->size == 16 && dst->size == 16))
vb@3605
   130
                return PEP_UNKNOWN_ERROR;
vb@3605
   131
vb@3605
   132
            for (int i=0; i < src->size; ++i)
vb@3605
   133
                dst->buf[i] ^= src->buf[i];
vb@3605
   134
        }
vb@2831
   135
    ||
vb@2831
   136
}
vb@2831
   137
vb@3781
   138
action newChallengeAndNegotiationBase {
vb@3601
   139
    // random new challenge
vb@3772
   140
    call "new_UUID" with "dst" > &session->sync_state.own.challenge
vb@3781
   141
    call "copy_UUID" {
vb@3781
   142
        with "src" > &session->sync_state.own.challenge
vb@3781
   143
        with "dst" > &session->sync_state.keysync.challenge
vb@3781
   144
    }
vb@2831
   145
vb@3781
   146
    // this is the random data we are using as a base
vb@3781
   147
    call "new_UUID" with "dst" > &session->sync_state.own.negotiation
vb@3782
   148
||
vb@3782
   149
    memset(session->sync_state.keysync.negotiation.buf, 0,
vb@3782
   150
            session->sync_state.keysync.negotiation.size);
vb@3782
   151
    memset(session->sync_state.comm_partner.negotiation.buf, 0,
vb@3782
   152
            session->sync_state.comm_partner.negotiation.size);
vb@3782
   153
||
vb@2831
   154
}
vb@2831
   155
vb@3601
   156
action useOwnChallenge call "copy_UUID" {
vb@3772
   157
    with "src" > &session->sync_state.own.challenge
vb@3773
   158
    with "dst" > &session->sync_state.keysync.challenge
vb@3601
   159
}
vb@3601
   160
vb@3781
   161
action openNegotiation {
vb@3510
   162
||
vb@3590
   163
    // sender key must be stable while transaction
vb@3773
   164
vb@3773
   165
    // we take the actual signature of the last message and store it in our
vb@3773
   166
    // state for the comm partner
vb@3779
   167
    assert(session->sync_state.transport.sender_fpr);
vb@3773
   168
vb@3779
   169
    free(session->sync_state.comm_partner.sender_fpr);
vb@3773
   170
vb@3779
   171
    session->sync_state.comm_partner.sender_fpr
vb@3779
   172
            = strdup(session->sync_state.transport.sender_fpr);
vb@3779
   173
    assert(session->sync_state.comm_partner.sender_fpr);
vb@3779
   174
    if (!session->sync_state.comm_partner.sender_fpr)
vb@3591
   175
        return PEP_OUT_OF_MEMORY;
vb@3590
   176
vb@3779
   177
    // we need a unique TID for the Negotiation with each single comm_partner
vb@3779
   178
    // we identify the comm_partners by their Challenge
vb@3779
   179
    // we derive the actual Negotiation TID by having random data and XORing it
vb@3779
   180
    // with comm_partner's Challenge
vb@3779
   181
vb@3781
   182
    // copy Negotiation base into buffer
vb@3779
   183
vb@3783
   184
||
vb@3605
   185
    call "copy_UUID" {
vb@3779
   186
        with "src" > &session->sync_state.own.negotiation
vb@3779
   187
        with "dst" > &session->sync_state.keysync.negotiation
vb@3779
   188
    }
vb@3783
   189
||
vb@3779
   190
vb@3779
   191
    // we're XORing this with the challenge of the comm_partner, which is in
vb@3779
   192
    // the buffer already
vb@3779
   193
vb@3783
   194
||
vb@3779
   195
    call "xor_UUID" {
vb@3773
   196
        with "src" > &session->sync_state.keysync.challenge
vb@3773
   197
        with "dst" > &session->sync_state.keysync.negotiation
vb@3605
   198
    }
vb@3783
   199
||
vb@3779
   200
vb@3779
   201
    // this is the Negotiation's TID for this comm_partner
vb@3779
   202
vb@3783
   203
||
vb@3591
   204
    call "copy_UUID" {
vb@3773
   205
        with "src" > &session->sync_state.keysync.negotiation
vb@3779
   206
        with "dst" > &session->sync_state.comm_partner.negotiation
vb@3591
   207
    }
vb@3510
   208
}
vb@3510
   209
vb@3779
   210
action storeNegotiation {
vb@3591
   211
||
vb@3591
   212
    // sender key must be stable while transaction
vb@3773
   213
vb@3773
   214
    // we take the actual signature of the last message and store it in our
vb@3773
   215
    // state for the comm partner
vb@3779
   216
    assert(session->sync_state.transport.sender_fpr);
vb@3773
   217
vb@3779
   218
    free(session->sync_state.comm_partner.sender_fpr);
vb@3773
   219
vb@3779
   220
    session->sync_state.comm_partner.sender_fpr
vb@3779
   221
            = strdup(session->sync_state.transport.sender_fpr);
vb@3779
   222
    assert(session->sync_state.comm_partner.sender_fpr);
vb@3779
   223
    if (!session->sync_state.comm_partner.sender_fpr)
vb@3591
   224
        return PEP_OUT_OF_MEMORY;
vb@3591
   225
vb@3591
   226
||
vb@3591
   227
    call "copy_UUID" {
vb@3773
   228
        with "src" > &session->sync_state.keysync.negotiation
vb@3779
   229
        with "dst" > &session->sync_state.comm_partner.negotiation
vb@3591
   230
    }
vb@2831
   231
}
vb@2831
   232
vb@2831
   233
function "show_handshake" {
vb@2831
   234
    param "type";
vb@2831
   235
    ||
vb@2831
   236
        assert(session->notifyHandshake);
vb@2831
   237
        if (!session->notifyHandshake)
vb@2831
   238
            return PEP_SYNC_NO_NOTIFY_CALLBACK;
vb@2831
   239
     
vb@3525
   240
    ||
vb@3525
   241
    choose {
vb@3791
   242
    when "$type = 'SYNC_NOTIFY_INIT_ADD_OUR_DEVICE' or $type = 'SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE' or $type = 'SYNC_NOTIFY_INIT_FORM_GROUP'"
vb@3525
   243
    ||
vb@3779
   244
        assert(session->sync_state.transport.from);
vb@3779
   245
        if (!session->sync_state.transport.from)
vb@2831
   246
            return PEP_ILLEGAL_VALUE;
vb@2831
   247
vb@3779
   248
        pEp_identity *from = session->sync_state.transport.from;
vb@2831
   249
        pEp_identity *me = NULL;
vb@2901
   250
        PEP_STATUS status = get_identity(session, from->address, from->user_id, &me);
vb@2831
   251
        assert(status == PEP_STATUS_OK);
vb@2831
   252
        if (status)
vb@2831
   253
            return status;
vb@3791
   254
        assert(strcmp(me->fpr, session->sync_state.comm_partner.sender_fpr) != 0);
vb@3791
   255
        
vb@2831
   256
        assert(me->fpr && me->fpr[0]);
vb@2831
   257
        if (!(me->fpr && me->fpr[0])) {
vb@2831
   258
            free_identity(me);
vb@2831
   259
            return PEP_ILLEGAL_VALUE;
vb@2831
   260
        }
vb@2831
   261
vb@2831
   262
        pEp_identity *partner = identity_dup(from);
vb@2831
   263
        if (!partner) {
vb@2831
   264
            free_identity(me);
vb@2831
   265
            return PEP_OUT_OF_MEMORY;
vb@2831
   266
        }
vb@3365
   267
vb@3779
   268
        assert(session->sync_state.comm_partner.sender_fpr);
vb@3779
   269
        if (session->sync_state.comm_partner.sender_fpr) {
vb@3379
   270
            free(partner->fpr);
vb@3779
   271
            partner->fpr = strdup(session->sync_state.comm_partner.sender_fpr);
vb@3791
   272
            assert(partner->fpr);
vb@3379
   273
            if (!partner->fpr) {
vb@3379
   274
                free_identity(me);
vb@3379
   275
                free_identity(partner);
vb@3379
   276
                return PEP_OUT_OF_MEMORY;
vb@3379
   277
            }
vb@3364
   278
        }
vb@2831
   279
vb@3722
   280
        free(partner->user_id);
vb@3722
   281
        partner->user_id = strdup("#NV");
vb@3722
   282
        assert(partner->user_id);
vb@3722
   283
        if (!partner->user_id) {
vb@3722
   284
            free_identity(me);
vb@3722
   285
            free_identity(partner);
vb@3722
   286
            return PEP_OUT_OF_MEMORY;
vb@3722
   287
        }
vb@3722
   288
vb@3791
   289
        assert(strcmp(me->fpr, partner->fpr) != 0);
vb@3047
   290
        status = session->notifyHandshake(me, partner, «$type»);
vb@2831
   291
        if (status)
vb@2831
   292
            return status;
vb@2831
   293
    ||
vb@3791
   294
    otherwise
vb@3791
   295
    ||
vb@3791
   296
        pEp_identity *me = new_identity(NULL, NULL, NULL, NULL);
vb@3791
   297
        pEp_identity *partner = new_identity(NULL, NULL, NULL, NULL);
vb@3791
   298
        assert(me && partner);
vb@3791
   299
        if (!(me && partner)) {
vb@3791
   300
            free_identity(me);
vb@3791
   301
            free_identity(partner);
vb@3791
   302
            return PEP_OUT_OF_MEMORY;
vb@3791
   303
        }
vb@3791
   304
vb@3791
   305
        PEP_STATUS status = session->notifyHandshake(me, partner, «$type»);
vb@3791
   306
        if (status)
vb@3791
   307
            return status;
vb@3791
   308
    ||
vb@3525
   309
    }
vb@2831
   310
}
vb@2831
   311
vb@2831
   312
action showSoleHandshake
vb@2831
   313
    call "show_handshake" with "type" > SYNC_NOTIFY_INIT_FORM_GROUP
vb@2831
   314
vb@2831
   315
action showJoinGroupHandshake
vb@2831
   316
    call "show_handshake" with "type" > SYNC_NOTIFY_INIT_ADD_OUR_DEVICE
vb@2831
   317
vb@2831
   318
action showGroupedHandshake
vb@2831
   319
    call "show_handshake" with "type" > SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE
vb@2831
   320
vb@3522
   321
action hideHandshakeDialog
vb@3522
   322
    call "show_handshake" with "type" > SYNC_NOTIFY_OVERTAKEN
vb@3522
   323
vb@3524
   324
action showDeviceAdded
vb@3524
   325
    call "show_handshake" with "type" > SYNC_NOTIFY_ACCEPTED_DEVICE_ADDED
vb@3524
   326
vb@3524
   327
action showGroupCreated
vb@3524
   328
    call "show_handshake" with "type" > SYNC_NOTIFY_ACCEPTED_GROUP_CREATED
vb@3524
   329
vb@3525
   330
action showBeingSole
vb@3525
   331
    call "show_handshake" with "type" > SYNC_NOTIFY_SOLE
vb@3525
   332
vb@3525
   333
action showBeingInGroup
vb@3525
   334
    call "show_handshake" with "type" > SYNC_NOTIFY_IN_GROUP
vb@3525
   335
vb@2914
   336
timeout KeySync
vb@2913
   337
    call "show_handshake" with "type" > SYNC_NOTIFY_TIMEOUT
vb@2913
   338
vb@3390
   339
action prepareOwnKeys
vb@3390
   340
||
vb@3390
   341
    stringlist_t *own_keys;
krista@3583
   342
    PEP_STATUS status = _own_keys_retrieve(session, &own_keys, PEP_idf_not_for_sync, true);
vb@3390
   343
    if (status)
vb@3390
   344
        return status;
vb@3390
   345
vb@3772
   346
    if (session->sync_state.own.keys)
vb@3772
   347
        free_stringlist(session->sync_state.own.keys);
vb@3772
   348
    session->sync_state.own.keys = own_keys;
vb@3394
   349
vb@3394
   350
    identity_list *il;
vb@3394
   351
    status = _own_identities_retrieve(session, &il, PEP_idf_not_for_sync);
vb@3394
   352
    if (status)
vb@3394
   353
        return status;
vb@3394
   354
vb@3773
   355
    IdentityList_from_identity_list(il, &session->sync_state.keysync.ownIdentities);
vb@3609
   356
    free_identity_list(il);
vb@3390
   357
||
vb@3390
   358
vb@2831
   359
action saveGroupKeys
vb@2831
   360
||
vb@3790
   361
    char *user_id = NULL;
vb@3790
   362
    PEP_STATUS status = get_default_own_userid(session, &user_id);
vb@3790
   363
    if (status)
vb@3790
   364
        return status;
vb@3790
   365
vb@3773
   366
    identity_list *il = IdentityList_to_identity_list(&session->sync_state.keysync.ownIdentities, NULL);
vb@3794
   367
    if (!il) {
vb@3794
   368
        free(user_id);
vb@2831
   369
        return PEP_OUT_OF_MEMORY;
vb@3794
   370
    }
vb@2831
   371
    
vb@3786
   372
    identity_list *oil = session->sync_state.own.identities;
vb@3786
   373
vb@2831
   374
    // BUG: this should be a transaction and been rolled back completely on error
vb@2831
   375
    for (identity_list *_il = il; _il && _il->ident; _il = _il->next) {
vb@3785
   376
        pEp_identity *ident = _il->ident;
vb@3785
   377
        bool is_own_already = false;
vb@3785
   378
vb@3790
   379
        status = is_own_address(session, ident->address, &is_own_already);
vb@3786
   380
        if (status) {
vb@3786
   381
            free_identity_list(il);
vb@3794
   382
            free(user_id);
vb@3786
   383
            return status;
vb@3786
   384
        }
vb@3786
   385
vb@3786
   386
        free(ident->user_id);
vb@3794
   387
        ident->user_id = strdup(user_id);
vb@3794
   388
        assert(ident->user_id);
vb@3794
   389
        if (!ident->user_id) {
vb@3794
   390
            free_identity_list(il);
vb@3794
   391
            free(user_id);
vb@3794
   392
            return PEP_OUT_OF_MEMORY;
vb@3794
   393
        }
vb@3786
   394
vb@3785
   395
        if (is_own_already) {
vb@3786
   396
            ident->comm_type = PEP_ct_pEp;
vb@3786
   397
            status = set_trust(session, ident);
vb@3785
   398
        }
vb@3785
   399
        else {
vb@3786
   400
            oil = identity_list_add(oil, ident);
vb@3786
   401
            if (!oil) {
vb@3786
   402
                free_identity_list(il);
vb@3794
   403
                free(user_id);
vb@3786
   404
                return PEP_OUT_OF_MEMORY;
vb@3786
   405
            }
vb@3785
   406
            status = myself(session, ident);
vb@3785
   407
        }
vb@2831
   408
        if (status) {
vb@2831
   409
            free_identity_list(il);
vb@3794
   410
            free(user_id);
vb@2831
   411
            return status;
vb@2831
   412
        }
vb@2831
   413
    }
vb@2831
   414
vb@3794
   415
    free(user_id);
vb@2831
   416
    free_identity_list(il);
vb@2831
   417
||
vb@2831
   418
vb@3815
   419
action ownKeysAreDefaultKeys
vb@3434
   420
||
vb@3434
   421
    PEP_STATUS status = PEP_STATUS_OK;
vb@3434
   422
vb@3786
   423
    // set flag for all keys; don't change anything else
vb@3772
   424
    for (identity_list *il = session->sync_state.own.identities; il && il->ident ; il = il->next) {
vb@3434
   425
        if (!(il->ident->flags && PEP_idf_not_for_sync)) {
vb@3434
   426
            status = set_identity_flags(session, il->ident, PEP_idf_devicegroup);
vb@3434
   427
            if (status)
vb@3434
   428
                return status;
vb@3434
   429
        }
vb@2831
   430
    }
vb@3434
   431
||
vb@2831
   432
vb@3815
   433
action receivedKeysAreDefaultKeys
vb@3525
   434
||
vb@3525
   435
    PEP_STATUS status = PEP_STATUS_OK;
vb@3786
   436
    // set flag for all keys
vb@3772
   437
    for (identity_list *il = session->sync_state.own.identities; il && il->ident ; il = il->next) {
vb@3527
   438
        if (!(il->ident->flags && PEP_idf_not_for_sync)) {
vb@3786
   439
            
vb@3527
   440
            status = set_identity_flags(session, il->ident, PEP_idf_devicegroup);
vb@3527
   441
            if (status)
vb@3527
   442
                return status;
vb@3527
   443
        }
vb@3527
   444
    }
vb@3527
   445
vb@3786
   446
    char *user_id = NULL;
vb@3786
   447
    status = get_default_own_userid(session, &user_id);
vb@3786
   448
    if (status)
vb@3786
   449
        return status;
vb@3786
   450
vb@3773
   451
    identity_list *il = IdentityList_to_identity_list(&session->sync_state.keysync.ownIdentities, NULL);
vb@3525
   452
    if (!il)
vb@3525
   453
        return PEP_OUT_OF_MEMORY;
vb@3525
   454
vb@3786
   455
    for (identity_list *_il = il; _il && _il->ident ; _il = _il->next) {
vb@3525
   456
        // replace partner's user_id with own user_id
vb@3786
   457
        free(_il->ident->user_id);
vb@3786
   458
        _il->ident->user_id = strdup(user_id);
vb@3786
   459
        assert(_il->ident->user_id);
vb@3786
   460
        if (!_il->ident->user_id) {
vb@3525
   461
            free_identity_list(il);
vb@3786
   462
            free(user_id);
vb@3525
   463
            return PEP_OUT_OF_MEMORY;
vb@3525
   464
        }
vb@3786
   465
    
vb@3786
   466
        const char *own_key = _il->ident->fpr;
vb@3786
   467
        _il->ident->fpr = NULL;
vb@3786
   468
        status = set_own_key(session, _il->ident, own_key);
vb@3525
   469
        if (status) {
vb@3525
   470
            free_identity_list(il);
vb@3786
   471
            free(user_id);
vb@3525
   472
            return status;
vb@3525
   473
        }
vb@3525
   474
    }
vb@3525
   475
vb@3525
   476
    free_identity_list(il);
vb@3786
   477
    free(user_id);
vb@3525
   478
||
vb@3406
   479
vb@3516
   480
action trustThisKey
vb@3516
   481
||
vb@3779
   482
    assert(session->sync_state.transport.from && session->sync_state.comm_partner.sender_fpr);
vb@3779
   483
    if (!(session->sync_state.transport.from && session->sync_state.comm_partner.sender_fpr))
vb@3516
   484
        return PEP_ILLEGAL_VALUE;
vb@3516
   485
vb@3779
   486
    pEp_identity *ident = identity_dup(session->sync_state.transport.from);
vb@3754
   487
    if (!ident)
vb@3754
   488
        return PEP_OUT_OF_MEMORY;
vb@3516
   489
    free(ident->fpr);
vb@3779
   490
    ident->fpr = strdup(session->sync_state.comm_partner.sender_fpr);
vb@3516
   491
    assert(ident->fpr);
vb@3754
   492
    if (!ident->fpr) {
vb@3754
   493
        free_identity(ident);
vb@3516
   494
        return PEP_OUT_OF_MEMORY;
vb@3754
   495
    }
vb@3516
   496
vb@3516
   497
    PEP_STATUS status = trust_own_key(session, ident);
vb@3754
   498
    if (status) {
vb@3754
   499
        free_identity(ident);
vb@3516
   500
        return status;
vb@3754
   501
    }
vb@3523
   502
vb@3773
   503
    OCTET_STRING_fromBuf(&session->sync_state.keysync.key, ident->fpr, strlen(ident->fpr));
vb@3754
   504
    free_identity(ident);
vb@3516
   505
||
vb@3516
   506
vb@3524
   507
action untrustThisKey
vb@3524
   508
||
vb@3779
   509
    assert(session->sync_state.transport.from && session->sync_state.comm_partner.sender_fpr);
vb@3779
   510
    if (!(session->sync_state.transport.from && session->sync_state.comm_partner.sender_fpr))
vb@3524
   511
        return PEP_ILLEGAL_VALUE;
vb@3524
   512
vb@3779
   513
    pEp_identity *ident = session->sync_state.transport.from;
vb@3524
   514
    free(ident->fpr);
vb@3779
   515
    ident->fpr = strdup(session->sync_state.comm_partner.sender_fpr);
vb@3524
   516
    assert(ident->fpr);
vb@3524
   517
    if (!ident->fpr)
vb@3524
   518
        return PEP_OUT_OF_MEMORY;
vb@3524
   519
vb@3524
   520
    PEP_STATUS status = key_reset_trust(session, ident);
vb@3524
   521
    if (status)
vb@3524
   522
        return status;
vb@3524
   523
vb@3773
   524
    OCTET_STRING_fromBuf(&session->sync_state.keysync.key, "", 0);
vb@3524
   525
||
vb@3524
   526
vb@3518
   527
action tellWeAreGrouped
vb@3518
   528
||
vb@3773
   529
    session->sync_state.keysync.is_group = true;
vb@3518
   530
||
vb@3518
   531
vb@3518
   532
action tellWeAreNotGrouped
vb@3518
   533
||
vb@3773
   534
    session->sync_state.keysync.is_group = false;
vb@3518
   535
||
vb@3518
   536
vb@2831
   537
action disable;