kylehuff / buildcrx Goto Github PK
View Code? Open in Web Editor NEWStandalone binary for Windows/Linux/Mac to pack signed chrome extension without needing the chrome binary
License: Other
Standalone binary for Windows/Linux/Mac to pack signed chrome extension without needing the chrome binary
License: Other
This is a request for support for password protected PEMs.
You'd have to call PEM_read_RSAPrivateKey with a pem_password_cb and supply it the password through userdata.
printf( "usage: %s <ZIP file> <PEM file> <PEM password or \"NULL\"> (optional <OUTPUT PATH/FILE>)\n", argv[0] );
int password_cb(char *buf, int size, int rwflag, void *userdata)
{
strcpy(buf, (char *)userdata);
return strlen(buf);
}
if (strcmpi(argv[3], "") == 0 || strcmpi(argv[3], "NULL") == 0)
privateKey = PEM_read_RSAPrivateKey (pemfile, NULL, NULL, NULL);
else
privateKey = PEM_read_RSAPrivateKey (pemfile, NULL, password_cb, argv[3]);
Hi Kyle - any idea why I get those three garbage characters after 'WebCapture' in the output copy/pasted below?
The resulting .crx seems to be accepted by Chrome without complaint.
Oddly, I seem to only see these when running buildcrx from the 'dos box', not when it runs from my .bat file.
c:\build\DotTwain\firefox-plugin\build\bin\WebCapture\MinSizeRel>buildcrx WebCapture.zip WebCapture.pem
Bulding a test ZIP file
strcat: WebCapture▄■(.crx
Extension name is WebCapture.zip, and will be WebCapture▄■(.crx
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC73IWLPvyPexoIWwmKV+Yz2Qti
XfQ0AFKjzyYy7DlWTtsfO6MJXwqt5JpCRSuSFK3/6KaG14k4uJrOe8H1tRLNQnok
AZBdzviF+s8Og8Y6qbA0PDxqjofqIQrQp8uSi6EtSxVqoz04nXyI9OChboGCvRaI
Wh5rcbVoxZtKdxNhaQIDAQAB
-----END PUBLIC KEY-----
Content Size: 1417742 (1384.51 KB)
RSA Keysize: 128, RSA (DER) size: 162
Signature Size: 128
Saved extension to WebCapture▄■(.crx
It would be great if the tool could also print out the extension's app id. Here is some code that I have scratched together real quick to do just that.
bool hexencode(char* buf, int size, char *target, int maxtarget) {
static const char hexChars[] = "0123456789ABCDEF";
int i = 0;
for (i = 0; i < size; ++i) {
target[(i * 2)] = hexChars[(buf[i] >> 4) & 0xf];
target[(i * 2) + 1] = hexChars[buf[i] & 0xf];
}
return true;
}
void hextoidalpha(char* id, int idsize) {
char x[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };
for (size_t i = 0; i < idsize; ++i) {
id[i] = x[id[i]-'0'] + 'a';
}
}
void generate_appid(char *buf, int size, char out[SHA256_DIGEST_LENGTH]) {
SHA256_CTX sha;
byte digest[SHA256_DIGEST_LENGTH];
char hexDigest[SHA256_DIGEST_LENGTH * 2] = {0};
SHA256_Init(&sha);
SHA256_Update (&sha, buf, size);
SHA256_Final(digest, &sha);
hexencode((char *)digest, SHA256_DIGEST_LENGTH, hexDigest, SHA256_DIGEST_LENGTH*2);
hextoidalpha(hexDigest, SHA256_DIGEST_LENGTH);
strncpy(out, hexDigest, SHA256_DIGEST_LENGTH);
}
Then in main function after you convert the RSA PublicKey to DER format
// Print the appid
char appid[SHA256_DIGEST_LENGTH] = {0};
generate_appid((char *)derkey,derlen,appid);
printf("appid: %.32s\n", appid);
When trying to compile with OpenSSL on MSVC2008, I ran into an issue where the OpenSSL libraries were not initialized prior to calling PEM_read_RSAPrivateKey.
OpenSSL_add_all_algorithms();
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
Also take a look at this StackOverflow article:
http://stackoverflow.com/questions/16310457/failed-to-read-private-key-from-pem-file-in-c
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.