Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong decryption when using exported keys #4

Open
dzobbe opened this issue Apr 14, 2020 · 0 comments
Open

Wrong decryption when using exported keys #4

dzobbe opened this issue Apr 14, 2020 · 0 comments

Comments

@dzobbe
Copy link

dzobbe commented Apr 14, 2020

Hi,

I am facing problems when exporting and importing keys in the cryptosystem. I mean, my cryptographic algorithm works fine when I generate every time new keys, but when I try to reuse the exported keys, it produces a wrong decryption. What I am doing wrong? Here is a snippet of code I implemented to make some tests.

Thank you

	pcs_public_key * pk2 = pcs_init_public_key();
	pcs_private_key * vk2 = pcs_init_private_key();
	hcs_random * hr2 = hcs_init_random();

	pcs_generate_key_pair(pk2, vk2, hr2, 2048);

	char * pkstr=pcs_export_public_key(pk2);
	char * vkstr=pcs_export_private_key(vk2);

	printf("ecco: %s\n",pkstr);

	// initialize data structures
	pcs_public_key * pk = pcs_init_public_key();
	pcs_private_key * vk = pcs_init_private_key();
	hcs_random * hr = hcs_init_random();
	
	pcs_import_public_key(pk, pkstr);
	pcs_import_private_key(vk, vkstr);

	printf("ecco: %s\n",pcs_export_public_key(pk));

	cout<<"test decr -----> "<<DecryptString(EncryptString("test"))<<endl<<endl;

	cout<<"Valid? "<<pcs_verify_key_pair(pk,vk)<<endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant