crypto++ and libhash++ ported

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
jojojoris
Posts: 255
Joined: Sun Mar 30, 2008 4:06 am

crypto++ and libhash++ ported

Post by jojojoris »

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
Last edited by jojojoris on Thu Mar 05, 2009 1:35 am, edited 1 time in total.

Code: Select all

int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Dariusc123456
Posts: 388
Joined: Tue Aug 12, 2008 12:46 am

Post by Dariusc123456 »

Can you upload it to sendspace.com?
jojojoris
Posts: 255
Joined: Sun Mar 30, 2008 4:06 am

Post by jojojoris »

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

Code: Select all

int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Post by coolkehon »

thanks dont know what it is for but i downloaded it i like ports to psp
jojojoris
Posts: 255
Joined: Sun Mar 30, 2008 4:06 am

Post by jojojoris »

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: Select all

#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&#40;"template", 0, 1, 1&#41;;

/* Define the main thread's attribute value &#40;optional&#41; */
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;

#define printf pspDebugScreenPrintf

long getFileSize&#40;const char *filename&#41;&#123;
	long size;
	FILE *pFile;
	pFile = fopen &#40;filename,"r"&#41;;
	fseek&#40; pFile, 0L, SEEK_END &#41;;
	size=ftell&#40; pFile &#41;;
	fclose&#40;pFile&#41;;
	return size;
&#125;

void encryptData&#40;const char *pakname,const char *filename,byte *key&#41;&#123;
	long filesize=getFileSize&#40;filename&#41;;
	FILE *pFile;

	pFile = fopen &#40;filename,"r"&#41;;
	byte iv&#91;AES&#58;&#58;BLOCKSIZE&#93;;
	AES&#58;&#58;Encryption aesEncryption&#40;key, AES&#58;&#58;DEFAULT_KEYLENGTH&#41;;
	CFB_Mode_ExternalCipher&#58;&#58;Encryption cfbEncryption&#40;aesEncryption, iv&#41;;

	byte plain&#91;filesize&#93;, cipher&#91;filesize&#93;;
	fread&#40;plain,filesize,1,pFile&#41;;
	fclose &#40;pFile&#41;;
	cfbEncryption.ProcessData&#40;cipher, plain, filesize&#41;;

	pFile = fopen&#40; pakname ,"wb"&#41;;
	fwrite &#40;cipher , 1 , filesize , pFile &#41;;
	fclose &#40;pFile&#41;;
&#125;

void decryptData&#40;const char *pakname,const char *filename,byte *key&#41;&#123;
	long filesize=getFileSize&#40;pakname&#41;;
	FILE *pFile;
	byte iv&#91;AES&#58;&#58;BLOCKSIZE&#93;;

	pFile = fopen&#40; pakname ,"r"&#41;;
	byte decry&#91;filesize&#93;, encry&#91;filesize&#93;;
	fread&#40;encry,filesize,1,pFile&#41;;
	fclose &#40;pFile&#41;;

	CFB_Mode<AES>&#58;&#58;Decryption cfbDecryption&#40;key, 16, iv&#41;;
	cfbDecryption.ProcessData&#40;decry, encry, filesize&#41;;


	pFile = fopen&#40; filename ,"wb"&#41;;
	fwrite &#40;decry , 1 , filesize , pFile &#41;;
	fclose &#40;pFile&#41;;
&#125;

int main&#40;int argc, char *argv&#91;&#93;&#41; &#123;
	pspDebugScreenInit&#40;&#41;;
	printf&#40;"Start test\n"&#41;;

	byte key&#91;&#93;="keytest";

	printf&#40;"Key is '%s'\n",key&#41;;

	encryptData&#40;"data.pak","test.zip",key&#41;;
	printf&#40;"encrypted \n"&#41;;
	decryptData&#40;"data.pak","data.zip",key&#41;;
	printf&#40;"decrypted \n"&#41;;

	sceKernelDelayThread&#40;5000000&#41;;
	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;
makefile:

Code: Select all

TARGET = template
OBJS = main.o

BUILD_PRX=1

INCDIR = 
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41;
ASFLAGS = $&#40;CFLAGS&#41;

EXTRA_TARGETS=EBOOT.PBP

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

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak

Code: Select all

int main&#40;&#41;&#123;
     SetupCallbacks&#40;&#41;;
     makeNiceGame&#40;&#41;;
     sceKernelExitGame&#40;&#41;;
&#125;
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Post by coolkehon »

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
jojojoris
Posts: 255
Joined: Sun Mar 30, 2008 4:06 am

Post by jojojoris »

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: Select all

int main&#40;&#41;&#123;
     SetupCallbacks&#40;&#41;;
     makeNiceGame&#40;&#41;;
     sceKernelExitGame&#40;&#41;;
&#125;
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Post by coolkehon »

cool thanks its nice to have aes encryption for psp mabye someone can make a truecrypt like program
Post Reply