1 2 Previous Next 18 Replies Latest reply: Jan 25, 2013 1:58 AM by Nara RSS

    Elliptive Curve Cryptography using ALG_EC_FP

    Nara
      Hi,

      I am a newbie in this domain.

      I am trying to Generate ECC key pair to Sign and Verify using the above program, but with the ALG_EC_FP and KeyBuilder Size LENGTH_EC_FP_256. But it fails during the genKeyPair() call with the return value 1 indicating that its an illegal value. Can you please help me why i am getting this error?

      I am using the JCOP 2.4.2 R2 Card.

      The Filed,A,B,G,S,R,W,K,N values are as shown below.

      byte[] valA= {(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
      (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01,
      (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
      (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
      (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
      (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
      (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
      (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFC};
      byte[] valFP = {(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
      (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01,
      (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
      (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
      (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
      (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
      (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
      (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF};
      byte[] valB={(byte)0x5A,(byte)0xC6,(byte)0x35,(byte)0xDB,
      (byte)0xAA,(byte)0x3A,(byte)0x93,(byte)0xE7,
      (byte)0xB3,(byte)0xEB,(byte)0xBD,(byte)0x55,
      (byte)0x76,(byte)0x98,(byte)0x86,(byte)0xBC,
      (byte)0x65,(byte)0x1D,(byte)0x06,(byte)0xB0,
      (byte)0xCC,(byte)0x53,(byte)0xB0,(byte)0xF6,
      (byte)0x3B,(byte)0xCE,(byte)0x3C,(byte)0x3E,
      (byte)0x27,(byte)0xD2,(byte)0x60,(byte)0x4B};
      byte[] valG={(byte)0x04,(byte)0x6B,(byte)0x17,(byte)0xD1,(byte)0xF2,
      (byte)0xE1,(byte)0x2C,(byte)0x42,(byte)0x47,
      (byte)0xF8,(byte)0xBC,(byte)0xE6,(byte)0xE5,
      (byte)0x63,(byte)0xA4,(byte)0x40,(byte)0xF2,
      (byte)0x77,(byte)0x03,(byte)0x7D,(byte)0x81,
      (byte)0x2D,(byte)0xEB,(byte)0x33,(byte)0xA0,
      (byte)0xF4,(byte)0xA1,(byte)0x39,(byte)0x45,
      (byte)0xD8,(byte)0x98,(byte)0xC2,(byte)0x96,
      (byte)0x4F,(byte)0xE3,(byte)0x42,(byte)0xE2,
      (byte)0xFE,(byte)0x1A,(byte)0x7F,(byte)0x9B,
      (byte)0x8E,(byte)0xE7,(byte)0xEB,(byte)0x4A,
      (byte)0x7C,(byte)0x0F,(byte)0x9E,(byte)0x16,
      (byte)0x2B,(byte)0xCE,(byte)0x33,(byte)0x57,
      (byte)0x6B,(byte)0x31,(byte)0x5E,(byte)0xCE,
      (byte)0xCB,(byte)0xB6,(byte)0x40,(byte)0x68,
      (byte)0x37,(byte)0xBF,(byte)0x51,(byte)0xF5};
      byte[] valN={(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
      (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
      (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
      (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
      (byte)0xBC,(byte)0xE6,(byte)0xFA,(byte)0xAD,
      (byte)0xA7,(byte)0x17,(byte)0x9E,(byte)0x84,
      (byte)0xF3,(byte)0xB9,(byte)0xCA,(byte)0xC2,
      (byte)0xFC,(byte)0x63,(byte)0x25,(byte)0x51,};

      byte[] valW={(byte)0x04,(byte)0x6B,(byte)0x17,(byte)0xD1,(byte)0xF2,
      (byte)0xE1,(byte)0x2C,(byte)0x42,(byte)0x47,
      (byte)0xF8,(byte)0xBC,(byte)0xE6,(byte)0xE5,
      (byte)0x63,(byte)0xA4,(byte)0x40,(byte)0xF2,
      (byte)0x77,(byte)0x03,(byte)0x7D,(byte)0x81,
      (byte)0x2D,(byte)0xEB,(byte)0x33,(byte)0xA0,
      (byte)0xF4,(byte)0xA1,(byte)0x39,(byte)0x45,
      (byte)0xD8,(byte)0x98,(byte)0xC2,(byte)0x96,
      (byte)0x4F,(byte)0xE3,(byte)0x42,(byte)0xE2,
      (byte)0xFE,(byte)0x1A,(byte)0x7F,(byte)0x9B,
      (byte)0x8E,(byte)0xE7,(byte)0xEB,(byte)0x4A,
      (byte)0x7C,(byte)0x0F,(byte)0x9E,(byte)0x16,
      (byte)0x2B,(byte)0xCE,(byte)0x33,(byte)0x57,
      (byte)0x6B,(byte)0x31,(byte)0x5E,(byte)0xCE,
      (byte)0xCB,(byte)0xB6,(byte)0x40,(byte)0x68,
      (byte)0x37,(byte)0xBF,(byte)0x51,(byte)0xF5};
      byte[] valS={(byte)0xC4,(byte)0x9D,(byte)0x36,(byte)0x08,
      (byte)0x86,(byte)0xE7,(byte)0x04,(byte)0x93,
      (byte)0x6A,(byte)0x66,(byte)0x78,(byte)0xE1,
      (byte)0x13,(byte)0x9D,(byte)0x26,(byte)0xB7,
      (byte)0x81,(byte)0x9F,(byte)0x7E,(byte)0x90};
      short k = (short)0x01;

      any help in this regard will be very much appreciated.
      Thanks in advance
      Nara
        • 1. Re: Elliptive Curve Cryptography using ALG_EC_FP
          801926
          Paste applet source, APDU log and script.
          • 2. Re: Elliptive Curve Cryptography using ALG_EC_FP
            Nara
            package ecc_test;

            import javacard.framework.*;
            import javacard.security.*;
            import javacard.framework.APDU;
            import javacard.framework.ISO7816;
            import javacard.framework.Applet;
            import javacard.framework.ISOException;
            import javacard.framework.SystemException;
            import javacard.framework.Util;
            import javacard.security.CryptoException;
            import javacard.security.DESKey;
            import javacard.security.Key;
            import javacard.security.KeyBuilder;
            import javacardx.crypto.Cipher;

            public class EccTest extends Applet {
                 
            private byte[] scratch;
            private byte[] outBuffer;
            private byte[] q;
                 
                 private static final short VERSION_INFO_MAJOR_MINOR = (short)0x0113;
                 
                 private static final short MAX_COMPONENT_SIZE = (short)88;
                 
                 private short keyLength;
                 private static final byte INS_PARAMETERS      = (byte)0x01;     
                 private static final byte GET_PARAM           = (byte)0x02;
                 private static final byte DO_SIG_TEST           = (byte)0x03;
                 
                 private KeyPair keyPairECC;
                 private KeyAgreement keyAgreement;
                 private ECPrivateKey ecPrivateKey;
                 private ECPublicKey ecPublicKey;
                 private MessageDigest messageDigest;
                 private Signature sig1;
                 private Signature sig2;

            EccTest() {
                 
                 this.q = JCSystem.makeTransientByteArray(MAX_COMPONENT_SIZE, JCSystem.CLEAR_ON_DESELECT);      
            scratch = JCSystem.makeTransientByteArray((short) 255, JCSystem.CLEAR_ON_DESELECT);
            outBuffer = JCSystem.makeTransientByteArray((short) 20, JCSystem.CLEAR_ON_DESELECT);
            keyAgreement = KeyAgreement.getInstance(KeyAgreement.ALG_EC_SVDP_DH, false);
            messageDigest = MessageDigest.getInstance(MessageDigest.ALG_SHA, false);
            sig1 = Signature.getInstance(Signature.ALG_ECDSA_SHA, false);
            sig2 = Signature.getInstance(Signature.ALG_ECDSA_SHA, false);
            }

                 public static void install(byte[] bArray, short bOffset, byte bLength) {
                      new EccTest().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
                 }

                 public void process(APDU apdu) {
                      short code = 0;
                      apdu.setIncomingAndReceive(); // beware of T=0
                      byte[] buf = apdu.getBuffer();

                      if (selectingApplet()) {
            Util.setShort(buf, (short) 0, VERSION_INFO_MAJOR_MINOR); //sets the buffer with the applet version no.
            apdu.setOutgoingAndSend((short) 0, (short) 2);
                           return;
                      }
                      
                      
                           switch (buf[ISO7816.OFFSET_INS]) {
                                case INS_PARAMETERS: //01
                                     
                                     /*PARAMETERS*/
                                     byte[] valA= {(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
                                                    (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01,
                                                    (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
                                                    (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
                                                    (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
                                                    (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
                                                    (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
                                                    (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFC};
                                     
                                     byte[] valFP = {(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
                                                         (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01,
                                                         (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
                                                         (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
                                                         (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
                                                         (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
                                                         (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
                                                         (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF};
                                     
                                     byte[] valB={(byte)0x5A,(byte)0xC6,(byte)0x35,(byte)0xDB,
                                                    (byte)0xAA,(byte)0x3A,(byte)0x93,(byte)0xE7,
                                                    (byte)0xB3,(byte)0xEB,(byte)0xBD,(byte)0x55,
                                                    (byte)0x76,(byte)0x98,(byte)0x86,(byte)0xBC,
                                                    (byte)0x65,(byte)0x1D,(byte)0x06,(byte)0xB0,
                                                    (byte)0xCC,(byte)0x53,(byte)0xB0,(byte)0xF6,
                                                    (byte)0x3B,(byte)0xCE,(byte)0x3C,(byte)0x3E,
                                                    (byte)0x27,(byte)0xD2,(byte)0x60,(byte)0x4B};
                                                                                                                     
                                     byte[] valG={(byte)0x04,(byte)0x6B,(byte)0x17,(byte)0xD1,(byte)0xF2,
                                                    (byte)0xE1,(byte)0x2C,(byte)0x42,(byte)0x47,
                                                    (byte)0xF8,(byte)0xBC,(byte)0xE6,(byte)0xE5,
                                                    (byte)0x63,(byte)0xA4,(byte)0x40,(byte)0xF2,
                                                    (byte)0x77,(byte)0x03,(byte)0x7D,(byte)0x81,
                                                    (byte)0x2D,(byte)0xEB,(byte)0x33,(byte)0xA0,
                                                    (byte)0xF4,(byte)0xA1,(byte)0x39,(byte)0x45,
                                                    (byte)0xD8,(byte)0x98,(byte)0xC2,(byte)0x96,
                                                    (byte)0x4F,(byte)0xE3,(byte)0x42,(byte)0xE2,
                                                    (byte)0xFE,(byte)0x1A,(byte)0x7F,(byte)0x9B,
                                                    (byte)0x8E,(byte)0xE7,(byte)0xEB,(byte)0x4A,
                                                    (byte)0x7C,(byte)0x0F,(byte)0x9E,(byte)0x16,
                                                    (byte)0x2B,(byte)0xCE,(byte)0x33,(byte)0x57,
                                                    (byte)0x6B,(byte)0x31,(byte)0x5E,(byte)0xCE,
                                                    (byte)0xCB,(byte)0xB6,(byte)0x40,(byte)0x68,
                                                    (byte)0x37,(byte)0xBF,(byte)0x51,(byte)0xF5};
                                     
                                     byte[] valN={(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
                                                    (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
                                                    (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
                                                    (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,
                                                    (byte)0xBC,(byte)0xE6,(byte)0xFA,(byte)0xAD,
                                                    (byte)0xA7,(byte)0x17,(byte)0x9E,(byte)0x84,
                                                    (byte)0xF3,(byte)0xB9,(byte)0xCA,(byte)0xC2,
                                                    (byte)0xFC,(byte)0x63,(byte)0x25,(byte)0x51,};

            byte[] valW={(byte)0x04,(byte)0x6B,(byte)0x17,(byte)0xD1,(byte)0xF2,
                                               (byte)0xE1,(byte)0x2C,(byte)0x42,(byte)0x47,
                                               (byte)0xF8,(byte)0xBC,(byte)0xE6,(byte)0xE5,
                                               (byte)0x63,(byte)0xA4,(byte)0x40,(byte)0xF2,
                                               (byte)0x77,(byte)0x03,(byte)0x7D,(byte)0x81,
                                               (byte)0x2D,(byte)0xEB,(byte)0x33,(byte)0xA0,
                                               (byte)0xF4,(byte)0xA1,(byte)0x39,(byte)0x45,
                                               (byte)0xD8,(byte)0x98,(byte)0xC2,(byte)0x96,
                                               (byte)0x4F,(byte)0xE3,(byte)0x42,(byte)0xE2,
                                               (byte)0xFE,(byte)0x1A,(byte)0x7F,(byte)0x9B,
                                               (byte)0x8E,(byte)0xE7,(byte)0xEB,(byte)0x4A,
                                               (byte)0x7C,(byte)0x0F,(byte)0x9E,(byte)0x16,
                                               (byte)0x2B,(byte)0xCE,(byte)0x33,(byte)0x57,
                                               (byte)0x6B,(byte)0x31,(byte)0x5E,(byte)0xCE,
                                               (byte)0xCB,(byte)0xB6,(byte)0x40,(byte)0x68,
                                               (byte)0x37,(byte)0xBF,(byte)0x51,(byte)0xF5};
                                     
                                     byte[] valS={(byte)0xC4,(byte)0x9D,(byte)0x36,(byte)0x08,
                                                    (byte)0x86,(byte)0xE7,(byte)0x04,(byte)0x93,
                                                    (byte)0x6A,(byte)0x66,(byte)0x78,(byte)0xE1,
                                                    (byte)0x13,(byte)0x9D,(byte)0x26,(byte)0xB7,
                                                    (byte)0x81,(byte)0x9F,(byte)0x7E,(byte)0x90};
                                     
                                     //short f2m = (short)0x09;
                                     short k = (short)0x01;
                                     
                                     /*SETTERS*/
                                     try {
                                          
                                     keyPairECC = new KeyPair(KeyPair.ALG_EC_FP, KeyBuilder.LENGTH_EC_FP_256);
                                     ecPrivateKey = (ECPrivateKey) keyPairECC.getPrivate();
                           ecPublicKey = (ECPublicKey) keyPairECC.getPublic();
                           ecPrivateKey.setFieldFP(valFP, (short)0,(short)valFP.length);
                                     ecPrivateKey.setA(valA,(short)0,(short)valA.length);
                                     ecPublicKey.setA(valA,(short)0,(short)valA.length);
                                     ecPrivateKey.setB(valB, (short)0, (short)valB.length);
                                     ecPublicKey.setB(valB, (short)0, (short)valB.length);
                                     ecPrivateKey.setG(valG, (short)0, (short)valG.length);
                                     ecPublicKey.setG(valG, (short)0, (short)valG.length);
                                     ecPrivateKey.setR(valN, (short)0, (short)valN.length);
                                     ecPublicKey.setR(valN, (short)0, (short)valN.length);
                                     ecPrivateKey.setS(valS,(short)0,(short)valS.length);
                                     ecPublicKey.setW(valW,(short)0,(short)valW.length);
                                     ecPrivateKey.setS(buf, ISO7816.OFFSET_CDATA, ISO7816.OFFSET_LC);
                                     ecPrivateKey.setK(k);
                                     ecPublicKey.setK(k);

            /*kEY GENERATION*/
                                     keyPairECC.genKeyPair();
                                     }
                                     catch (CryptoException ce)           {code = ce.getReason();}
                                     catch (SystemException se)           {code = (short)0xE000;}
                                     catch (NullPointerException ne) {code = (short)0xE001;}
                                     catch (CardRuntimeException cre){code = (short)0xE002;}
                                     catch (ArithmeticException ae) {code = (short)0xE003;}
                                     catch (ArrayIndexOutOfBoundsException aie) {code = (short)0xE004;}
                                     catch (ArrayStoreException ase) {code = (short)0xE005;}
                                     catch (ClassCastException cce) {code = (short)0xE006;}
                                     catch (RuntimeException re)      {code = (short)0xE007;}
                                     catch (Exception ex)                {code = (short)0xE008;}
                                     Util.setShort(buf, (short) 0, code);
                                     apdu.setOutgoingAndSend((short) 0, (short) 2);
                                break;
                                
                                case GET_PARAM:     //0x02
                                     //keyLength= 113;
                           keyPairECC = new KeyPair(KeyPair.ALG_EC_FP, KeyBuilder.LENGTH_EC_FP_256);
                                     ecPrivateKey = (ECPrivateKey) keyPairECC.getPrivate();
                           ecPublicKey = (ECPublicKey) keyPairECC.getPublic();
                                     keyPairECC.genKeyPair();
                                     getValues(buf,apdu);
                                     
                                     /*
                                     * expected parameters for keylength = 113
                                     a = 00 30 88 25 0C A6 E7 C7 FE 64 9C E8 58 20 F7
                                     b = 00 E8 BE E4 D3 E2 26 07 44 18 8B E0 E9 C7 23
                                     G = 04 00 9D 73 61 6F 35 F4 AB 14 07 D7 35 62 C1
                                     0F 00 A5 28 30 27 79 58 EE 84 D1 31 5E D3 18 86
                                     S = 10E723AB 14D696E6 76875615 1756FEBF 8FCB49A9
                                     n = 010000 00000000 00D9CCEC 8A39E56F
                                     */
                                break;
                                     
                                case DO_SIG_TEST: //0x03
                                     code=0;
                                     if(!ecPrivateKey.isInitialized() || !ecPublicKey.isInitialized())
                                          code = (short)0xE000;
                                     else
                                          code = checkSignAndVerify(buf,apdu);
                                     Util.setShort(buf, (short) 0, code);
                                     apdu.setOutgoingAndSend((short) 0, (short) 2);     
                                     break;
                                default:
                                     ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
                           }
                 }
                 
                 
                 
            void getValues(byte[] buf, APDU apdu)
            {
                 byte[] tmp= new byte[200];
                 short[] dim= new short[6];
                 short dimTot=0;     
                 byte[] stuff={(byte)0xff};
                 dim[0]=ecPublicKey.getA(tmp,(short)0);
                 dimTot = dim[0];
                 Util.arrayCopy(stuff,(short)0,tmp,(short)dimTot,(short)1);
                 ++dimTot;
                 dim[1]=ecPublicKey.getB(tmp,(short)dimTot);
                 dimTot += dim[1];
                 Util.arrayCopy(stuff,(short)0,tmp,(short)dimTot,(short)1);
                 ++dimTot;
                 dim[2]=ecPublicKey.getG(tmp,(short)dimTot);
                 dimTot += dim[2];
                 Util.arrayCopy(stuff,(short)0,tmp,(short)dimTot,(short)1);
                 ++dimTot;
                 dim[3]=ecPublicKey.getR(tmp,(short)dimTot);
                 dimTot += dim[3];
                 Util.arrayCopy(stuff,(short)0,tmp,(short)dimTot,(short)1);
                 ++dimTot;
                 dim[4]=ecPublicKey.getW(tmp,(short)dimTot);
                 dimTot += dim[4];
                 Util.arrayCopy(stuff,(short)0,tmp,(short)dimTot,(short)1);
                 ++dimTot;
                 Util.setShort(tmp, (short)dimTot, (short)ecPublicKey.getSize());
                 dimTot+=2;
                 Util.arrayCopy(tmp,(short)0,buf,(short)0,(short)dimTot);
                 apdu.setOutgoingAndSend((short) 0, (short)dimTot);
                 }
                 
                 
            private short checkSignAndVerify(byte[] buf,APDU apdu) {
                      // sign
                      sig1.init(ecPrivateKey, Signature.MODE_SIGN);
                      short sLen = sig1.sign(buf, (short) 0, (short)(buf[ISO7816.OFFSET_LC] & (short)0x00FF), scratch, (short) 0);
                      
                      // verify
                      sig2.init(ecPublicKey, Signature.MODE_VERIFY);
                      
                      
                      // check if signature can be verified
                      if (!sig2.verify(buf, (short) 0, (short)(buf[ISO7816.OFFSET_LC] & (short)0x00FF), scratch, (short) 0, (short) sLen))
                           return (short) 0xA000;
                      else
                           return (short)sLen;
            }
            }

            I could get all the parameters from certicom except the W value. Hence i have used the same value for W as of G. Can you please tel me whether the parameter values that i am using is correct or not?
            If not then what are the parameters i should be using?
            • 3. Re: Elliptive Curve Cryptography using ALG_EC_FP
              Adriaan
              From your code I deduce that you want to generate a keypair. You should not set the W field because it will be generated (along with the private key) based on the other fields.

              Btw it is a good to keep in mind that not all chips/OSes support all algorithms listed in the JavaCard API - different vendors support different algorithms.
              • 4. Re: Elliptive Curve Cryptography using ALG_EC_FP
                Nara
                Thanks for the reply Adriaan.

                Yes i am trying to generate the KeyPair to use the keypair for signing and verifying. I want to generate using ALG_EC_FP. I ding set the W field and tried to generate the KEyPair. I still get the same return value. i.e 01 indicating that its an invalid value. Are there any other changes i need to incorporate?

                I am using a Java Card 2.4.2 R2 card. I am told that it supports ECC, Do you think otherwise?

                Any help in this regard will be greatly appreciated.

                Thanks
                Nara
                • 5. Re: Elliptive Curve Cryptography using ALG_EC_FP
                  Adriaan
                  Try with Fp_192. If that doesn't work, double check with the vendor that the chip supports ECC Fp.

                  This forum should have examples of using Java Card ECC.
                  • 6. Re: Elliptive Curve Cryptography using ALG_EC_FP
                    893199
                    1) Create a blank ECPublicKey, then set its curve parameters. (as noted before, don't set the W value)
                    2) Create a blank ECPrivateKey, then set its curve parameters. (As noted before, don't set the actual private value - the S value)
                    3) Create a key pair using the public/private keys above (e.g. use the other constructor for KeyPair)
                    4) Do a genKeyPair using that key pair.

                    Make sure you use the same curve parameters for both public and private keys.
                    • 7. Re: Elliptive Curve Cryptography using ALG_EC_FP
                      Nara
                      I tried with FP_192 also. Still i get the same error. I cross checked the datasheet of our product and yes it does support ALG_EC_FP.

                      I am not able to identify what i am doing wrongly. Can you find any mistake?
                      • 8. Re: Elliptive Curve Cryptography using ALG_EC_FP
                        Nara
                        I get the same response in both my approaches.

                        First i try to set the parameters FP,A,B,G,R and K and then if i try to generate the Keypair i get the illegal value crypto exception.

                        Second i create a blank ECPublicKey and ECPrivateKey and then try to generate the Keypair. I still get the illegal value crypto exception.

                        How should i go about now?

                        Any help in this regard will be appreciated.

                        Thanks
                        Nara
                        • 9. Re: Elliptive Curve Cryptography using ALG_EC_FP
                          816119
                          check parameters, especially G.
                          also try with non-initialized keys, default curves must be taken.
                          • 10. Re: Elliptive Curve Cryptography using ALG_EC_FP
                            Nara
                            Hi,

                            Trying to generate keypair using non initialized keys also failed with the error illegal value crypto exception.

                            I am using the FP,A,B,G and R values specified by certicom.
                            • 11. Re: Elliptive Curve Cryptography using ALG_EC_FP
                              816119
                              Trying to generate keypair using non initialized keys also failed with the error illegal value crypto exception.
                              i suppose jcop does not have default parameters for LENGTH_EC_FP_256, but it works with LENGTH_EC_FP_192.
                              • 12. Re: Elliptive Curve Cryptography using ALG_EC_FP
                                Nara
                                Hi,

                                I tried with LENGTH_EC_FP_192 also. It doesn't work either.

                                I think i am out of all possibilities and hope now.
                                • 13. Re: Elliptive Curve Cryptography using ALG_EC_FP
                                  816119
                                  i tested code and it works ok with non-initialized keys and LENGTH_EC_FP_192 on simulator and JCOP 2.4.1 card

                                  Edited by: 666 on 24.01.2013 0:47
                                  • 14. Re: Elliptive Curve Cryptography using ALG_EC_FP
                                    Nara
                                    The keys are initialized to default automatically when you call GenKeyPair() right?

                                    But for me the GenKeyPair itself fails. Irrespective of whether i initialize the the keys are not.

                                    I am using a JCOP 2.4.2 R2 Card.
                                    1 2 Previous Next