diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2013-04-27 11:39:36 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2013-04-27 11:39:36 +0000 |
commit | f3d22ea361554a090112ccaeb4290d14964a283d (patch) | |
tree | c1c789232a52cfb6a0a8c00d796fdc54d68ebb59 /protocols/Skype/keypacker/keypacker.cpp | |
parent | c7fa62a343fe1e5937602c216ec5d7e597462768 (diff) |
added instruction how to build skypekit libs
cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@4551 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype/keypacker/keypacker.cpp')
-rw-r--r-- | protocols/Skype/keypacker/keypacker.cpp | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/protocols/Skype/keypacker/keypacker.cpp b/protocols/Skype/keypacker/keypacker.cpp index 117fa20f93..c9833a41ac 100644 --- a/protocols/Skype/keypacker/keypacker.cpp +++ b/protocols/Skype/keypacker/keypacker.cpp @@ -1,5 +1,5 @@ #include "stdafx.h"
- +
void *buf;
static const char base64Fillchar = '='; // used to mark partial words at the end
@@ -60,7 +60,7 @@ char * encode(unsigned char *inbuf, unsigned int inlen, char formatted) *(curr++) = 0;
return (char *)buf;
}
- +
unsigned int decodeSize(char * data)
{
if ( !data) return 0;
@@ -130,7 +130,7 @@ unsigned char decode(char * data, unsigned char *buf, int len) }
}
#undef BASE64DECODE_READ_NEXT_CHAR
- +
unsigned char *decode(char * data, int *outlen)
{
if ( !data) { *outlen = 0; return (unsigned char*)""; }
@@ -141,68 +141,68 @@ unsigned char *decode(char * data, int *outlen) if( !decode(data, (unsigned char*)buf, len)) { return NULL; }
return (unsigned char*)buf;
}
- -int main() -{ - aes_context ctx; - FILE *fin, *fout; - - int t = strlen(MY_KEY); - int basecodedkey = encodeLength(strlen(MY_KEY), false); - buf = malloc(basecodedkey + 1); - unsigned char *tmpk = (unsigned char *)malloc(basecodedkey + 1); - tmpk = (unsigned char *)encode((unsigned char*)MY_KEY, strlen(MY_KEY), false); +
+int main()
+{
+ aes_context ctx;
+ FILE *fin, *fout;
+
+ int t = strlen(MY_KEY);
+ int basecodedkey = encodeLength(strlen(MY_KEY), false);
+ buf = malloc(basecodedkey + 1);
+ unsigned char *tmpk = (unsigned char *)malloc(basecodedkey + 1);
+ tmpk = (unsigned char *)encode((unsigned char*)MY_KEY, strlen(MY_KEY), false);
tmpk[basecodedkey] = 0;
char *output = (char*)malloc(basecodedkey + 17);
strcpy(output, "#define MY_KEY \"");
strcat(output, (const char*)tmpk);
strcat(output, "\"");
- fout = fopen("..\\..\\..\\..\\SkypeKit\\key.h", "wb"); - fputs((const char*)output, fout); - fclose(fout); + fout = fopen("key.h", "wb");
+ fputs((const char*)output, fout);
+ fclose(fout);
free(buf);
- - aes_set_key( &ctx, (BYTE*)MY_KEY, 128); - - //encrypt - fin = fopen("..\\..\\..\\..\\SkypeKit\\keypair.crt", "rb"); - fseek(fin, 0, SEEK_END); - long fileSize = ftell(fin); - rewind (fin); - int needbyte = 16 - fileSize%16; - int corsize = fileSize + needbyte; +
+ aes_set_key( &ctx, (BYTE*)MY_KEY, 128);
+
+ //encrypt
+ fin = fopen("keypair.crt", "rb");
+ fseek(fin, 0, SEEK_END);
+ long fileSize = ftell(fin);
+ rewind (fin);
+ int needbyte = 16 - fileSize%16;
+ int corsize = fileSize + needbyte;
unsigned char *inBuf = (unsigned char*)malloc(corsize + 1);
unsigned char *locbuf = (unsigned char*)malloc(corsize + 1);
fread(inBuf, fileSize, 1, fin);
- fclose(fin); - memset(inBuf+fileSize, 0, needbyte); - inBuf[corsize] = 0; + fclose(fin);
+ memset(inBuf+fileSize, 0, needbyte);
+ inBuf[corsize] = 0;
for (int i = 0; i < corsize; i+=16) {
aes_encrypt(&ctx, inBuf+i, locbuf+i);
}
free(inBuf);
- locbuf[corsize] = 0; //cert should be null terminated - int basecoded = encodeLength(corsize, false); - buf = malloc(basecoded + 1); - unsigned char *tmp = (unsigned char *)malloc(basecoded + 1); - tmp = (unsigned char *)encode(locbuf, corsize, false); + locbuf[corsize] = 0; //cert should be null terminated
+ int basecoded = encodeLength(corsize, false);
+ buf = malloc(basecoded + 1);
+ unsigned char *tmp = (unsigned char *)malloc(basecoded + 1);
+ tmp = (unsigned char *)encode(locbuf, corsize, false);
tmp[basecoded] = 0;
free(locbuf);
- fout = fopen("..\\..\\..\\..\\SkypeKit\\keypair.bin", "wb"); - fputs((const char*)tmp, fout); - fclose(fout); + fout = fopen("keypair.bin", "wb");
+ fputs((const char*)tmp, fout);
+ fclose(fout);
free(buf);
- //free(tmp); todo:fix - - //decrypt - fin = fopen("..\\..\\..\\..\\SkypeKit\\keypair.bin", "rb"); - fseek(fin, 0, SEEK_END); - long fileSizeD = ftell(fin); - rewind(fin); + //free(tmp); todo:fix
+
+ //decrypt
+ fin = fopen("keypair.bin", "rb");
+ fseek(fin, 0, SEEK_END);
+ long fileSizeD = ftell(fin);
+ rewind(fin);
unsigned char *inBufD = (unsigned char*)malloc(fileSizeD);
fread(inBufD, fileSizeD, 1, fin);
- fclose(fin); - inBufD[fileSizeD] = 0; + fclose(fin);
+ inBufD[fileSizeD] = 0;
int basedecoded = decodeSize((char*)inBufD);
unsigned char *bufD = (unsigned char*)malloc(basedecoded + 1);
unsigned char *tmpD = (unsigned char*)malloc(basedecoded + 1);
@@ -210,13 +210,13 @@ int main() for (int i = 0; i < basedecoded; i += 16) {
aes_decrypt(&ctx, tmpD+i, bufD+i);
}
- bufD[basedecoded] = 0; //cert should be null terminated - //free(inBufD); todo:fix - free(tmpD); - fout = fopen("..\\..\\..\\..\\SkypeKit\\keypair.crt.decrypted", "wb"); - fputs((const char*)bufD, fout); - fclose(fout); - free(bufD); - - return 0; + bufD[basedecoded] = 0; //cert should be null terminated
+ //free(inBufD); todo:fix
+ free(tmpD);
+ fout = fopen("keypair.crt.decrypted", "wb");
+ fputs((const char*)bufD, fout);
+ fclose(fout);
+ free(bufD);
+
+ return 0;
}
\ No newline at end of file |