Merge pull request #1970 from famedly/td/macv2

fix: use macv2 for correct base64 encoding
This commit is contained in:
td 2025-03-28 13:17:37 +01:00 committed by GitHub
commit 7e7e518074
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View File

@ -1238,7 +1238,10 @@ class QRCode {
const knownKeyAgreementProtocols = ['curve25519-hkdf-sha256', 'curve25519'];
const knownHashes = ['sha256'];
const knownHashesAuthentificationCodes = ['hkdf-hmac-sha256'];
const knownHashesAuthentificationCodes = [
'hkdf-hmac-sha256.v2',
'hkdf-hmac-sha256',
];
class _KeyVerificationMethodSas extends _KeyVerificationMethod {
_KeyVerificationMethodSas({required super.request});
@ -1396,6 +1399,8 @@ class _KeyVerificationMethodSas extends _KeyVerificationMethod {
if (possibleMessageAuthenticationCodes.isEmpty) {
return false;
}
// intersect should make sure we choose v2 over the dep'd one
messageAuthenticationCode = possibleMessageAuthenticationCodes.first;
final possibleAuthenticationTypes = _intersect(
knownAuthentificationTypes,
@ -1560,7 +1565,9 @@ class _KeyVerificationMethodSas extends _KeyVerificationMethod {
}
String _calculateMac(String input, String info) {
if (messageAuthenticationCode == 'hkdf-hmac-sha256') {
if (messageAuthenticationCode == 'hkdf-hmac-sha256.v2') {
return sas!.calculate_mac_fixed_base64(input, info);
} else if (messageAuthenticationCode == 'hkdf-hmac-sha256') {
return sas!.calculate_mac(input, info);
} else {
throw Exception('Unknown message authentification code');

View File

@ -25,7 +25,7 @@ dependencies:
js: ^0.6.3
markdown: ^7.1.1
mime: ">=1.0.0 <3.0.0"
olm: ^2.0.2
olm: ^3.1.0
random_string: ^2.3.1
sdp_transform: ^0.3.2
slugify: ^2.0.0