|
563 | 563 |
|
564 | 564 | my $user2_id = $user2->user_id; |
565 | 565 | my $user2_device = $user2->device_id; |
| 566 | + my $user2_device_key_id_hash = "EmkqvokUn8p+vQAGZitOk4PWjp7Ukp3txV2TbMPEiBQ"; |
| 567 | + my $user2_device_key_id = "ed25519:$user2_device_key_id_hash"; |
566 | 568 |
|
567 | 569 | my $room_id; |
568 | 570 |
|
|
573 | 575 | "user_id" => $user2_id, |
574 | 576 | "usage" => ["self_signing"], |
575 | 577 | "keys" => { |
576 | | - "ed25519:EmkqvokUn8p+vQAGZitOk4PWjp7Ukp3txV2TbMPEiBQ" |
577 | | - => "EmkqvokUn8p+vQAGZitOk4PWjp7Ukp3txV2TbMPEiBQ", |
| 578 | + $user2_device_key_id => $user2_device_key_id_hash, |
578 | 579 | }, |
579 | 580 | }; |
580 | 581 | sign_json( |
|
639 | 640 | })->then( sub { |
640 | 641 | sign_json( |
641 | 642 | $device, secret_key => $self_signing_secret_key, |
642 | | - origin => $user2_id, key_id => "ed25519:EmkqvokUn8p+vQAGZitOk4PWjp7Ukp3txV2TbMPEiBQ" |
| 643 | + origin => $user2_id, key_id => $user2_device_key_id |
643 | 644 | ); |
644 | 645 | log_if_fail "sent signature", $device; |
645 | | - $cross_signature = $device->{signatures}->{$user2_id}->{"ed25519:EmkqvokUn8p+vQAGZitOk4PWjp7Ukp3txV2TbMPEiBQ"}; |
| 646 | + $cross_signature = $device->{signatures}->{$user2_id}->{$user2_device_key_id}; |
646 | 647 | matrix_upload_signatures( $user2, { |
647 | 648 | $user2_id => { |
648 | 649 | $user2_device => $device |
|
661 | 662 | # On server0, user1 syncs until they see user2's device. This is racey: the |
662 | 663 | # sync may complete before the signatures have uploaded, propagated over |
663 | 664 | # federation to server 1 and then over replication to the sync worker. |
| 665 | + # |
| 666 | + # Thus we wait for the expected signatures to show up inside this function. |
664 | 667 | matrix_get_e2e_keys( $user1, $user2_id )->then( sub { |
665 | 668 | my ( $content ) = @_; |
666 | 669 | log_if_fail "key query content2", $content; |
667 | | - $content->{device_keys}{$user2_id}{$user2_device}{"signatures"} |
| 670 | + my $sigs = $content->{device_keys}{$user2_id}{$user2_device}{"signatures"} |
668 | 671 | or die "No 'signatures' key present"; |
| 672 | + |
| 673 | + exists $sigs->{$user2_id} |
| 674 | + && exists $sigs->{$user2_id}{$user2_device_key_id} |
| 675 | + && $sigs->{$user2_id}{$user2_device_key_id} eq $cross_signature |
| 676 | + or die "Expected cross-signature ($user2_device_key_id}->$cross_signature not visible"; |
| 677 | + |
669 | 678 | Future->done( $content ); |
670 | 679 | }); |
671 | 680 | }; |
|
674 | 683 |
|
675 | 684 | log_if_fail "key query content3", $content; |
676 | 685 |
|
677 | | - # Check that fetching the devices again returns the new signature |
678 | | - assert_json_keys( $content->{device_keys}->{$user2_id}->{$user2_device}, "signatures" ); |
679 | | - |
680 | | - assert_deeply_eq( $content->{device_keys}->{$user2_id}->{$user2_device}->{signatures}, { |
681 | | - $user2_id => { |
682 | | - "ed25519:EmkqvokUn8p+vQAGZitOk4PWjp7Ukp3txV2TbMPEiBQ" => $cross_signature |
683 | | - }, |
684 | | - } ); |
685 | | - |
686 | 686 | # Check that we still see the master key when querying the devices. |
687 | 687 | assert_json_keys( $content->{master_keys}, $user2_id ); |
688 | 688 | assert_json_keys( $content->{master_keys}->{$user2_id}, "keys"); |
|
0 commit comments