Skip to content

port encryptFile to use PGPainless #1059

Description

@tomholub

Part of #1051

Relevant test here https://github.com/FlowCrypt/flowcrypt-mobile-core/blob/master/source/test.ts#L53

Only port encryptFile for now (which results in binary - unarmored - output). Don't port decryptFile because there are many error scenarios that we want to behave the same as before.

for(constkeypairNameofallKeypairNames.filter(name=>name!='expired')){ava.default(`encryptFile -> decryptFile ${keypairName}`,asynct=>{const{ pubKeys, keys }=getKeypairs(keypairName);constname='myfile.txt';constcontent=Buffer.from([10,20,40,80,160,0,25,50,75,100,125,150,175,200,225,250]);const{data: encryptedFile,json: encryptJson}=awaitrequest('encryptFile',{ pubKeys, name },content);expectEmptyJson(encryptJson);expectData(encryptedFile);const{data: decryptedContent,json: decryptJson}=awaitrequest('decryptFile',{ keys },encryptedFile);expect(decryptJson).to.deep.equal({success: true, name });expectData(decryptedContent,'binary',content);t.pass();});}

Current implementation here https://github.com/FlowCrypt/flowcrypt-mobile-core/blob/master/source/mobile-interface/endpoints.ts

publicencryptFile=async(uncheckedReq: any,data: Buffers): Promise<Buffers>=>{constreq=ValidateInput.encryptFile(uncheckedReq);constencrypted=awaitPgpMsg.encrypt({pubkeys: req.pubKeys,data: Buf.concat(data),filename: req.name,armor: false})asOpenPGP.EncryptBinaryResult;returnfmtRes({},encrypted.message.packets.write());}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions