Page 1 of 1

Some APDU commands in OpenPGPApplet

Posted: Sat Nov 28, 2015 6:06 am
by Ellisun
The following APDU commands is the result of my learning applet, it's contains:
1. All the types of RSA signature data length, it can be any length.
2. Generate three types of Key Pair
3. Encrpt and Decrypt commands

Code: Select all

//select
00A4040010D276000124010200000600000001000000;


//verify pw3
00200083083132333435363738;
//Generate sig_key Key Pair
0047800001b6;
//Get remain data
//00C000000F;

//verify pw1
0020008106313233343536;
//Compute Signature
002a9e9a051122334455;
00C0000001;

//verify pw1
0020008106313233343536;
//Compute Signature
002a9e9a10000102030405060708090A0B0C0D0E0F;
00C0000001;

//verify pw1
0020008106313233343536;
//Compute Signature
002a9e9aF50102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5;
00C0000001;

//verify pw1
0020008106313233343536;
//Compute Signature
002a9e9a0101;
00C0000001;

//verify pw1
0020008106313233343536;
//Compute Signature
002a9e9aF50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001;
00C0000001;

//verify pw1
0020008206313233343536;
//GENERATE auth_key Key Pair
0047800001a4;
00C000000F;

//encrpt
8088000006112233445566;
00C00001;

//Generate dec_key Key Pair
0047800001b8;
00C000000F;

//decrypt
102A8186 + lc + encrypted data part1;
102A8086 + lc + encrypted data part2;
802A808600;

//Put Data 80DATag+Lc+data
80DA7F2106010203040506;

//Get data. 80CA + Tag +00
80CA7F2100;


Re: Some APDU commands in OpenPGPApplet

Posted: Wed Dec 02, 2015 8:57 am
by whitexiao
I used this commands in my script, when I sent the "102A8186..." to decrypt data, it always returned 0x6F00. Why this happened?

Re: Some APDU commands in OpenPGPApplet

Posted: Wed Dec 02, 2015 11:39 pm
by UNKNwYSHSA
Where's the data of command DECRYPT DATA from?
You should understand the process flow:
1 The OpenPGP Applet generate dec_key pair, output the public key, save the private key in the card;
2 The client application encrypt data with the public key.
3 The he card decrypt the encrypted data using the private key.

Re: Some APDU commands in OpenPGPApplet

Posted: Fri Dec 04, 2015 5:48 am
by whitexiao
UNKNwYSHSA wrote:Where's the data of command DECRYPT DATA from?
You should understand the process flow:
1 The OpenPGP Applet generate dec_key pair, output the public key, save the private key in the card;
2 The client application encrypt data with the public key.
3 The he card decrypt the encrypted data using the private key.


That is say, I will generate dec_key pair, and get the public key, then I encrypt a data outside card and decrypt this data inside card?

Re: Some APDU commands in OpenPGPApplet

Posted: Fri Dec 04, 2015 11:06 pm
by UNKNwYSHSA
Yes.

If i send one mail to you, i encrypt the mail using the public key. you can decrypt the mail with the card (contains private key).

Re: Some APDU commands in OpenPGPApplet

Posted: Fri Dec 04, 2015 11:19 pm
by whitexiao
UNKNwYSHSA wrote:Yes.

If i send one mail to you, i encrypt the mail using the public key. you can decrypt the mail with the card (contains private key).


I know, but where I can find a tool to encrypt datas. Can you please give me a tool? :D

Re: Some APDU commands in OpenPGPApplet

Posted: Sat Dec 05, 2015 1:56 am
by Regist
I also need such a tool, can you give me an algorithm tool too?

Re: Some APDU commands in OpenPGPApplet

Posted: Tue Dec 08, 2015 5:59 am
by UNKNwYSHSA
Here is a opensource application PortablePGP, maybe fit your needs: http://sourceforge.net/projects/ppgp/
The following is the main frame of this application: