Zip Archive Reader

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Zip Archive Reader

Postby peterfhannon » Wed Sep 26, 2012 8:50 am

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
peterfhannon
Techie
 
Posts: 20
Joined: Tue Sep 18, 2012 9:34 am

Re: Zip Archive Reader

Postby magreenblatt » Wed Sep 26, 2012 10:13 am

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.
magreenblatt
Site Admin
 
Posts: 10802
Joined: Fri May 29, 2009 6:57 pm

Re: Zip Archive Reader

Postby Czarek » Thu Sep 27, 2012 2:46 am

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.
Last edited by Czarek on Wed Mar 20, 2013 9:36 am, edited 1 time in total.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. Connect with me on LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1905
Joined: Sun Nov 06, 2011 2:12 am

Re: Zip Archive Reader

Postby peterfhannon » Fri Sep 28, 2012 7:58 am

Thanks for the information, I'll give this a go thanks,

Peter
peterfhannon
Techie
 
Posts: 20
Joined: Tue Sep 18, 2012 9:34 am

Re: Zip Archive Reader

Postby Czarek » Sat Sep 29, 2012 12:49 am

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.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. Connect with me on LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1905
Joined: Sun Nov 06, 2011 2:12 am

Re: Zip Archive Reader

Postby peterfhannon » Thu Oct 04, 2012 5:22 am

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
peterfhannon
Techie
 
Posts: 20
Joined: Tue Sep 18, 2012 9:34 am

Re: Zip Archive Reader

Postby Czarek » Thu Oct 04, 2012 8:46 am

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
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. Connect with me on LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1905
Joined: Sun Nov 06, 2011 2:12 am

Re: Zip Archive Reader

Postby peterfhannon » Thu Oct 04, 2012 10:35 am

Hi Czarek,

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

Regards,

Peter
peterfhannon
Techie
 
Posts: 20
Joined: Tue Sep 18, 2012 9:34 am

Re: Zip Archive Reader

Postby macmaina » Wed Jan 22, 2014 7:46 am

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.
macmaina
Newbie
 
Posts: 3
Joined: Fri Oct 04, 2013 1:39 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 23 guests