Page 1 of 1

Zip Archive Reader

PostPosted: Wed Sep 26, 2012 8:50 am
by peterfhannon
I'm very interested in using the zip archive reader, in combination with encryption as a way to bundle and protect my html5 app code and resources, as I have read is being done with WBEA.
I'm wondering if anyone can explain the steps involved in that, or point me at a tutorial before go and start digging around the WBEA source code to figure out how its done.

Thanks,

Peter

Re: Zip Archive Reader

PostPosted: Wed Sep 26, 2012 10:13 am
by magreenblatt
An implementation can generally be summarized as follows:

1. Create a zip archive containing your application and a manifest file.
2. Encrypt the zip archive using an external tool.
3. When the application starts show a wait screen while decrypting the zip archive on a secondary thread.
4. Once the zip archive is decrypted read the manifest file and navigate to the entry point (e.g. index.html).
5. Load files from the zip archive using CefZipReader/CefZipArchive and either a custom scheme handler or resource request interception.

Re: Zip Archive Reader

PostPosted: Thu Sep 27, 2012 2:46 am
by Czarek
I am also interested in zip encryption, I plan to make it a built-in feature to CEF Python, I've been also looking at WBEA sources some time ago, as I remember it uses AES encryption.

It seems simple in .NET, an exmple of creating an encrypted zip:
http://www.componentace.com/zip-aes-enc ... -sharp.htm

WBEA uses a very simple and optimized library, there are only 2 files: AES.h and AES.cpp.

The tool for encrypting is quite simple, see source at WBEA/app/encrypt/encrypt.cpp:
Code: Select all
... reading in_buf.....
AES aes;
aes.SetParameters(key_length);
aes.StartEncryption((unsigned char*)key);
aes.Encrypt(in_buf, out_buf, num_blocks);

FILE *out_file = fopen(argv[2], "wb");
if (out_file)
{
  fwrite(out_buf, 1, size_blocks, out_file);
  fclose(out_file);
}


Decrypting code can be found in WBEA/app/resource_util.cpp:

Code: Select all
.... reading in_buf ....
AES aes;
aes.SetParameters(key_length);
aes.StartDecryption((unsigned char*)key);
aes.Decrypt(in_buf, out_buf, num_blocks);

// Remove padding from the end of the contents.
for(; out_buf[size-1] == 0xFF; --size) ;

*out_bytes = out_buf;
*out_bytes_size = size;


It uses CefZipArchive and CefStreamReader to load the archive, see WBEA/app/wbea.cpp > WbeaHandler::LoadArchive().

I don't see WBEA using CefSchemeHandler which is strange, it uses some kind of hack, it loads this url in browser:
Code: Select all
http://__app/index.html

And then uses RequestHandler::BeforeResourceLoad to set the content of the resource.

It probably does this hack as it uses some old version of CEF that didn't have implemented SchemeHandler as of that time.

Re: Zip Archive Reader

PostPosted: Fri Sep 28, 2012 7:58 am
by peterfhannon
Thanks for the information, I'll give this a go thanks,

Peter

Re: Zip Archive Reader

PostPosted: Sat Sep 29, 2012 12:49 am
by Czarek
Seems like CefZipReader can open password protected file, see function:
Code: Select all
public virtual bool OpenFile( const CefString& password )= 0;

It's definitely not AES encryption, but maybe that is enough for you, it would simplify things, no need for external libraries, only a few lines of code using Cef functions.

Re: Zip Archive Reader

PostPosted: Thu Oct 04, 2012 5:22 am
by peterfhannon
I now have the first part working - I load a zip file at startup and have a new scheme that serves files from that zip - this is working nicely.

However, I attempted to password protect my zip, and supply a password to CefZipReader, but this didn't work. CefZipReader is unable to open the file.

I can follow WBEA and implement my encryption & decryption myself, however I would prefer the simple option of leaving it up to CefZipReader if possible. Does anyone have this working? Would you mind sharing what you did to get this working?

Thanks in advance,

Peter

Re: Zip Archive Reader

PostPosted: Thu Oct 04, 2012 8:46 am
by Czarek
Are you using the latest version of CEF 1.1180.832 that was released 2 days ago? It comes with a fix for Issue 496 "Problem with Zip files protected by password": http://code.google.com/p/chromiumembedd ... ail?id=496

Re: Zip Archive Reader

PostPosted: Thu Oct 04, 2012 10:35 am
by peterfhannon
Hi Czarek,

I have just updated to the latest version and its now fully working - thanks for your help :).

Regards,

Peter

Re: Zip Archive Reader

PostPosted: Wed Jan 22, 2014 7:46 am
by macmaina
I have been looking for the documentation for WBEA desktop application wrapper and the webpage http://asterclick.drclue.net/WBEA.html seems to be down.

Any help?

Thank you.