New attachment storage system

This commit is contained in:
Fedor Indutny 2024-07-11 12:44:09 -07:00 committed by GitHub
parent 273e1ccb15
commit 28664a606f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
161 changed files with 2418 additions and 1562 deletions

View file

@ -582,6 +582,8 @@ describe('Crypto', () => {
...splitKeys(keys),
size: FILE_CONTENTS.byteLength,
theirDigest: encryptedAttachment.digest,
getAbsoluteAttachmentPath:
window.Signal.Migrations.getAbsoluteAttachmentPath,
});
plaintextPath = window.Signal.Migrations.getAbsoluteAttachmentPath(
decryptedAttachment.path
@ -623,6 +625,8 @@ describe('Crypto', () => {
keys,
plaintext: path ? { absolutePath: path } : { data },
dangerousIv,
getAbsoluteAttachmentPath:
window.Signal.Migrations.getAbsoluteAttachmentPath,
});
ciphertextPath = window.Signal.Migrations.getAbsoluteAttachmentPath(
@ -635,6 +639,8 @@ describe('Crypto', () => {
...splitKeys(keys),
size: data.byteLength,
theirDigest: encryptedAttachment.digest,
getAbsoluteAttachmentPath:
window.Signal.Migrations.getAbsoluteAttachmentPath,
});
plaintextPath = window.Signal.Migrations.getAbsoluteAttachmentPath(
decryptedAttachment.path
@ -745,6 +751,8 @@ describe('Crypto', () => {
const previouslyEncrypted = await encryptAttachmentV2ToDisk({
keys,
plaintext: { data: FILE_CONTENTS },
getAbsoluteAttachmentPath:
window.Signal.Migrations.getAbsoluteAttachmentPath,
});
await testV2RoundTripData({
@ -784,6 +792,8 @@ describe('Crypto', () => {
const encryptedAttachment = await encryptAttachmentV2ToDisk({
keys,
plaintext: { absolutePath: FILE_PATH },
getAbsoluteAttachmentPath:
window.Signal.Migrations.getAbsoluteAttachmentPath,
});
ciphertextPath = window.Signal.Migrations.getAbsoluteAttachmentPath(
encryptedAttachment.path
@ -838,6 +848,8 @@ describe('Crypto', () => {
keys,
plaintext: { absolutePath: FILE_PATH },
dangerousIv: { iv: dangerousTestOnlyIv, reason: 'test' },
getAbsoluteAttachmentPath:
window.Signal.Migrations.getAbsoluteAttachmentPath,
});
ciphertextPath = window.Signal.Migrations.getAbsoluteAttachmentPath(
encryptedAttachmentV2.path
@ -872,6 +884,8 @@ describe('Crypto', () => {
innerEncryptedAttachment = await encryptAttachmentV2ToDisk({
keys: innerKeys,
plaintext: { absolutePath: plaintextAbsolutePath },
getAbsoluteAttachmentPath:
window.Signal.Migrations.getAbsoluteAttachmentPath,
});
innerCiphertextPath =
window.Signal.Migrations.getAbsoluteAttachmentPath(
@ -883,6 +897,8 @@ describe('Crypto', () => {
plaintext: { absolutePath: innerCiphertextPath },
// We (and the server!) don't pad the second layer
dangerousTestOnlySkipPadding: true,
getAbsoluteAttachmentPath:
window.Signal.Migrations.getAbsoluteAttachmentPath,
});
outerCiphertextPath =
@ -921,6 +937,8 @@ describe('Crypto', () => {
size: FILE_CONTENTS.byteLength,
theirDigest: encryptResult.innerEncryptedAttachment.digest,
outerEncryption: splitKeys(outerKeys),
getAbsoluteAttachmentPath:
window.Signal.Migrations.getAbsoluteAttachmentPath,
});
plaintextPath = window.Signal.Migrations.getAbsoluteAttachmentPath(
@ -974,6 +992,8 @@ describe('Crypto', () => {
size: data.byteLength,
theirDigest: encryptResult.innerEncryptedAttachment.digest,
outerEncryption: splitKeys(outerKeys),
getAbsoluteAttachmentPath:
window.Signal.Migrations.getAbsoluteAttachmentPath,
});
plaintextPath = window.Signal.Migrations.getAbsoluteAttachmentPath(
decryptedAttachment.path
@ -1024,6 +1044,8 @@ describe('Crypto', () => {
aesKey: splitKeys(outerKeys).aesKey,
macKey: splitKeys(innerKeys).macKey, // wrong mac!
},
getAbsoluteAttachmentPath:
window.Signal.Migrations.getAbsoluteAttachmentPath,
}),
/Bad outer encryption MAC/
);