Skip to Main Content

Java Card

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

starting with java card and key generation

843851Sep 13 2010 — edited Sep 22 2010
Hello, i'm a student and i'm doing a project related with java card. I'm starting with it and i'm getting blocked so many times, thats the reason why i'm here because I supose that it's a really simple problem but i don't find the way to solve it

I want to do a program that receive and exponent and modulus, and generate the rsa key, but i don't find how to initialize the rsa key, this is my code
	public void process(APDU apdu) {
		// Good practice: Return 9000 on SELECT
		if (selectingApplet()) {
			return;
		}

		byte[] buf = apdu.getBuffer();
		short len = (short)((short) buf[(short)ISO7816.OFFSET_LC] & (short)0x00FF);
		short numBytes = apdu.setIncomingAndReceive();
		
		while (numBytes < len)
			numBytes += apdu.receiveBytes((short)((short)ISO7816.OFFSET_CDATA+numBytes));
		switch (buf[ISO7816.OFFSET_INS]) {
		case (byte) 0xB0: //enviem el missatge
			break;
		case (byte) 0x10: //enviem l'exponent
			Key.setExponent(buf, ISO7816.OFFSET_CDATA, len);
			break;
		case (byte) 0x20: //enviem el modul
			Key.setModulus(buf, ISO7816.OFFSET_CDATA, len);
			break;
			
		default:
			// good practice: If you don't know the INStruction, say so:
			ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
		}
	}
Summarizing, i think I found the way to put into a key the modulus and the exponent that are sent throw the apdu, but i have to initilize a rsa key and i can't.
I hope it is a simple problem and can be solved simply :)

Thanks for reading my post and sorry for my english, It's not as good as I wanted jejej
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 20 2010
Added on Sep 13 2010
6 comments
335 views