#1 2019-03-18 10:59:17

MC
Member
Registered: 2012-10-04
Posts: 21

Public-key Asymmetric Cryptography via SynECC for large files

Hello,

I am studying the sample project "mORMot\SQLite3\Samples\33 - ECC" and its documentation.

My goal is to use this library for backup software and it's very well suited for my needs.

But I need to be able to encrypt and decrypt large files (> 4 Gb).

My first tests show that an insufficient memory error is encountered with large files.

Unless I'm mistaken, I think it is due to the use of "StringFromFile" and "FileFromString" functions in "SynECC" and "ECCProcess" units.
These functions read/write a file content into/from a String.

Do I need to modify TECC* objects to handle large files ?

If so, do you have any suggestions or recommendations ?

Could my changes be added to the mormot framework ?

Thank you very much

Offline

#2 2019-03-18 15:38:57

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,134
Website

Re: Public-key Asymmetric Cryptography via SynECC for large files

It is a known limitation of the current .synecc file format.

What you could do is use the ECC too to encrypt a small file containing a password, then use it for ciphering...

Or compile the tool for 64-bit, which should be able to allocate huge memory buffers (but likely to be slow, and untested yet).

Offline

#3 2019-03-19 06:15:17

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Public-key Asymmetric Cryptography via SynECC for large files

MC wrote:

Do I need to modify TECC* objects to handle large files ?

If so, do you have any suggestions or recommendations ?

Could my changes be added to the mormot framework ?

Good idea! May be use memory mapped file? I think ab will accept your changes if you don't break any compiler supported by mORMot smile


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#4 2019-03-19 08:14:08

MC
Member
Registered: 2012-10-04
Posts: 21

Re: Public-key Asymmetric Cryptography via SynECC for large files

Hello ab,

I am studying the "SynECC.pas" to see if I could make changes to handle large files.

It's not as simple as I thought !

And it requires a change of TECIESHeader.size from Cardinal to Int64.

How I could change TECIESHeader.size in a way acceptable for you ?

Would you accept 2 new function TECCCertificate.EncryptLargeFile and TECCCertificateSecret.DecryptLargeFile ?

thank you

Offline

#5 2019-03-19 08:34:20

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Public-key Asymmetric Cryptography via SynECC for large files

@MC,

I suggest you to create a new pull request at https://github.com/synopse/mORMot/pulls so that ab can review it.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#6 2019-03-19 13:19:35

MC
Member
Registered: 2012-10-04
Posts: 21

Re: Public-key Asymmetric Cryptography via SynECC for large files

The "StringFromFile" and "FileFromString" functions are present in several units needed by the ECC program and the modification is too difficult for me.

This was an opportunity for me to think globally about my project (backup software).

I thought to make the transfer of large files by internet by dividing them into several small pieces to avoid having to transfer everything again in case of error and to parallelize their download in case of restoration.

So, I decided to encrypt these pieces and not the entire file.

With small pieces (<50 MB), ECC works very well and is fast!

Thank you for taking the time to answer me.

Have a good day.

Offline

#7 2019-03-19 14:09:53

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,134
Website

Re: Public-key Asymmetric Cryptography via SynECC for large files

Yes, small pieces are the best option.

Offline

Board footer

Powered by FluxBB