forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

crypto++ and libhash++ ported

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Wed Mar 04, 2009 5:07 am    Post subject: crypto++ and libhash++ ported Reply with quote

I've ported libcrypto++ an libhash++ to the psp.

I hope i made the makefile portable. It compiles/installs fine using my windows VISTA+minpspw.

libcrypto++
Sendspace mirror:
http://www.sendspace.com/file/ynspg2

libhash++
Sendspace mirror:
http://www.sendspace.com/file/x0xfae
_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}


Last edited by jojojoris on Thu Mar 05, 2009 1:35 am; edited 1 time in total
Back to top
View user's profile Send private message
Dariusc123456



Joined: 12 Aug 2008
Posts: 394

PostPosted: Wed Mar 04, 2009 9:44 am    Post subject: Reply with quote

Can you upload it to sendspace.com?
Back to top
View user's profile Send private message AIM Address
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Thu Mar 05, 2009 1:36 am    Post subject: Reply with quote

Dariusc123456 wrote:
Can you upload it to sendspace.com?

Done
_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Back to top
View user's profile Send private message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Thu Mar 05, 2009 1:43 am    Post subject: Reply with quote

thanks dont know what it is for but i downloaded it i like ports to psp
Back to top
View user's profile Send private message MSN Messenger
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Tue Mar 10, 2009 4:52 am    Post subject: Reply with quote

well you can encrypt and decrypt things with this.

I made an example today which shows a working way to decrypt and encrypt a file using AES:

main.cpp
Code:
#include <pspkernel.h>
#include <pspdebug.h>

#include <cstdio>

#include "cryptopp/modes.h"
#include "cryptopp/aes.h"

using namespace CryptoPP;

/* Define the module info section */
PSP_MODULE_INFO("template", 0, 1, 1);

/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);

#define printf pspDebugScreenPrintf

long getFileSize(const char *filename){
   long size;
   FILE *pFile;
   pFile = fopen (filename,"r");
   fseek( pFile, 0L, SEEK_END );
   size=ftell( pFile );
   fclose(pFile);
   return size;
}

void encryptData(const char *pakname,const char *filename,byte *key){
   long filesize=getFileSize(filename);
   FILE *pFile;

   pFile = fopen (filename,"r");
   byte iv[AES::BLOCKSIZE];
   AES::Encryption aesEncryption(key, AES::DEFAULT_KEYLENGTH);
   CFB_Mode_ExternalCipher::Encryption cfbEncryption(aesEncryption, iv);

   byte plain[filesize], cipher[filesize];
   fread(plain,filesize,1,pFile);
   fclose (pFile);
   cfbEncryption.ProcessData(cipher, plain, filesize);

   pFile = fopen( pakname ,"wb");
   fwrite (cipher , 1 , filesize , pFile );
   fclose (pFile);
}

void decryptData(const char *pakname,const char *filename,byte *key){
   long filesize=getFileSize(pakname);
   FILE *pFile;
   byte iv[AES::BLOCKSIZE];

   pFile = fopen( pakname ,"r");
   byte decry[filesize], encry[filesize];
   fread(encry,filesize,1,pFile);
   fclose (pFile);

   CFB_Mode<AES>::Decryption cfbDecryption(key, 16, iv);
   cfbDecryption.ProcessData(decry, encry, filesize);


   pFile = fopen( filename ,"wb");
   fwrite (decry , 1 , filesize , pFile );
   fclose (pFile);
}

int main(int argc, char *argv[]) {
   pspDebugScreenInit();
   printf("Start test\n");

   byte key[]="keytest";

   printf("Key is '%s'\n",key);

   encryptData("data.pak","test.zip",key);
   printf("encrypted \n");
   decryptData("data.pak","data.zip",key);
   printf("decrypted \n");

   sceKernelDelayThread(5000000);
   sceKernelExitGame();
   return 0;
}


makefile:
Code:
TARGET = template
OBJS = main.o

BUILD_PRX=1

INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS)
ASFLAGS = $(CFLAGS)

EXTRA_TARGETS=EBOOT.PBP

LIBDIR =
LIBS= -lcryptopp -lstdc++ -lm
LDFLAGS =

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Back to top
View user's profile Send private message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Thu Apr 30, 2009 5:00 am    Post subject: Reply with quote

cool thanks and whats the hash one for is hash the same thing but i thought those were for verifying like md5 although i've heard of md5 encryption also will have to look up this stuff
Back to top
View user's profile Send private message MSN Messenger
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Thu Apr 30, 2009 6:43 am    Post subject: Reply with quote

libhash++ is just hashes link MD5 and SHA

libcrypto++ has encryption like AES etc. (and md5 as sha things) so you can decrypt it back.

I even don't know what those all does...
I ported them and the sees to work (at least the things i tested).
_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Back to top
View user's profile Send private message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Thu Apr 30, 2009 10:49 pm    Post subject: Reply with quote

cool thanks its nice to have aes encryption for psp mabye someone can make a truecrypt like program
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group