This discussion is archived
1 2 3 Previous Next 40 Replies Latest reply: Jan 21, 2013 1:03 AM by PhHein Go to original post RSS
  • 30. Re: Elliptic curve cryptography (ECC)
    843851 Newbie
    Currently Being Moderated
    What Java Card exception do you get? Also provide the APDU log.
  • 31. Re: Elliptic curve cryptography (ECC)
    843851 Newbie
    Currently Being Moderated
    It is working now...

    The exception was 6F 00... was problem with my code...

    JCOP Simulator does not support ECC.

    JCOP Card support ECC for F2M.

    Regards
    Abheesh S
  • 32. Re: Elliptic curve cryptography (ECC)
    843851 Newbie
    Currently Being Moderated
    The JCOP simulation supports ECC GF(p). Of course only if the base product supports it, which is JCOP v2.4 and v2.4.1. ECC F2m is not supported by the simulation.
  • 33. Re: Elliptic curve cryptography (ECC)
    843851 Newbie
    Currently Being Moderated
    I do not know what are the differences for selection betwen exam 1 and 2.

    exam 1:
    _ecPrivatKey = (ECPrivateKey) KeyBuilder.buildKey(
                  KeyBuilder.TYPE_EC_F2M_PRIVATE,
                  KeyBuilder.LENGTH_EC_F2M_113, false);
    _ecPublicKey = (ECPublicKey) KeyBuilder.buildKey(
                  KeyBuilder.TYPE_EC_F2M_PUBLIC,
                  KeyBuilder.LENGTH_EC_F2M_113, false);
    and exam 2:
    keyPairECC = new KeyPair(KeyPair.ALG_EC_F2M,
                  KeyBuilder.LENGTH_EC_F2M_113);
     keyPairECC.genKeyPair();
     _ecPrivatKey = (ECPrivateKey) keyPairECC.getPrivate();
     _ecPublicKey = (ECPublicKey) keyPairECC.getPublic();
    Could you tell me Which is better for use
    Thanks;

    and next what about this my strukture?: Is It correct?
    exam 3:
    private KeyPair keyPairECC;
    private static ECPrivateKey _ecPrivatKey;
    private static ECPublicKey _ecPublicKey;
    
    keyPairECC = new KeyPair((ECPublicKey) KeyBuilder.buildKey(
                  KeyBuilder.TYPE_EC_F2M_PUBLIC,
                  KeyBuilder.LENGTH_EC_F2M_113, false),
                  (ECPrivateKey) KeyBuilder.buildKey(
                       KeyBuilder.TYPE_EC_F2M_PRIVATE,
                       KeyBuilder.LENGTH_EC_F2M_113, false));
    
             keyPairECC.genKeyPair();
             
             _ecPrivatKey = (ECPrivateKey) keyPairECC.getPrivate();
             _ecPublicKey = (ECPublicKey) keyPairECC.getPublic();
    Edited by: johny3212 on Aug 13, 2009 12:44 AM
  • 34. Re: Elliptic curve cryptography (ECC)
    843851 Newbie
    Currently Being Moderated
    Exam 1:

    It just allocates the keys, but do not initialize it. You can't use the keys until you set the values for all the parameters (domain parameters).

    Exam 2:

    The genKeyPair() initializes with default domain parameters. So, the keys can be used.

    About the last qn,

    It is correct. But, you don't need something like that...
  • 35. Re: Elliptic curve cryptography (ECC)
    843851 Newbie
    Currently Being Moderated
    Thanks for helping
  • 36. Re: Elliptic curve cryptography (ECC)
    843851 Newbie
    Currently Being Moderated
    Hi All;

    I have a problem.
    I have my program for data signature.
    I use :
    Signature algorithm ALG_ECDSA_SHA

    The input buffer of data to be signed:
    private byte[] signArray = { (byte) 0x11, (byte) 0x22, (byte) 0x33,
             (byte) 0x44, (byte) 0x55, (byte) 0x66, (byte) 0x77, (byte) 0x88 };
    and my sign code:
    _sign1.init(_ecPrivatKey, Signature.MODE_SIGN);
    
         _sign1.update(signArray, (short) 0, (short) signArray.length);
    
         short signLength = _sign1.sign(signArray, (short) 0,
              (short) signArray.length, scratch, (short) 0);
    and my problem is, that when I two times (and more) sign the data (signArray), each time I have different values in output buffer (scratch). Only frst four bytes are equal.
    Is It OK?
    Shouldn't there be the same output data (scratch), when I sign the same input data (signArray) with the same sign key (ECPrivateKey)?

    exam:
    sign 1 :
    signArray: 1122334455667788
    
    scratch: 
    30 2E 02 15 03 5D B0 87 AE 07 AC 3E 67 0D F5 78    0....].....>g..x
    8E C7 BF 77 38 AA E9 13 D4 02 15 01 DD 5B 59 C0    ...w8........[Y.
    64 71 B9 F3 58 4C 08 35 74 74 F1 B4 78 36 4F 81
    _____________________________________________________________
    sign 2:
    
    signArray: 1122334455667788
    
    scratch: 
    30 2E 02 15 02 A0 CC C2 03 D8 CA 11 77 25 8B 07    0...........w%..
    2B DF 07 5F EF 31 25 D3 EE 02 15 01 48 74 D9 AF    +.._.1%.....Ht..
    8F 09 0A EF D3 11 C1 B6 CF 79 AD DE 85 49 4F 2F
    _____________________________________________________________
    sign 3:
    
    signArray: 1122334455667788
    
    scratch: 
    30 2E 02 15 00 A5 88 EA 1D 7C CE 5E EA 3E 4A E2    0........|.^.>J.
    0B CC DA F2 D5 FF E5 40 0E 02 15 02 9C 20 D1 08    .......@..... ..
    76 62 01 00 0C 13 4A 56 32 CB 66 4F AA 09 E8 E9
    Why I have different results for ouput data? :). Is it OK? Where is a problem?

    and It can be problem in my source kode. Can you check this?:
    http://sly.emtest.sk/cert/signature.txt

    command for my source code:
    http://sly.emtest.sk/cert/conzole.txt

    -> send d00D111100 SIGN and VERIFY Data Array
    -> send d0041111010300 return value for signet data (byte)



    Edited by: johny3212 on Aug 21, 2009 4:43 AM

    Edited by: johny3212 on Aug 21, 2009 4:50 AM
  • 37. Re: Elliptic curve cryptography (ECC)
    843851 Newbie
    Currently Being Moderated
    First of all, a comment on your coding style. You name your Applet 'Applet'. Same name as the base class. It's probably OK according to Java, but that's quite confusing.

    Second, you don't just sign the signArray, but 2 x signArray. Read carefully and learn what the difference between Signature.update() and Signature.sign() is.

    Last, your output is ok. ECDSA includes a random part in the algorithm, which is generated by the card. [http://en.wikipedia.org/wiki/Elliptic_Curve_DSA|http://en.wikipedia.org/wiki/Elliptic_Curve_DSA]
    Suppose Alice wants to send a signed message to Bob. Initially, the curve parameters (q,FR,a,b,G,n,h) must be agreed upon. Also, Alice must have a key pair suitable for elliptic curve cryptography, consisting of a private
    key dA (a randomly selected integer in the interval [1,n − 1]) and a public key QA (where QA = dAG). Let Ln be the bit length of the group order n. ..
  • 38. Re: Elliptic curve cryptography (ECC)
    843851 Newbie
    Currently Being Moderated
    yes i know....
    Hi all,

    I want to verify my sign array with OpenSSL library, but I have a problem:

    I am using in JavaCard: ALG_ECDSA_SHA and for generate keys LENGTH_EC_F2M_163 , ALG_EC_F2M
    result for this:
    private key: 21B, 
    public key 43B 
    signLenght 48B r,s sequnce 
    hash diggest is 20B.
    and the lengts are incorrect for OpenSSL, because I have aplication which use library OpenSSL and I am using algorithm:
    #define SN_sect163k1          "sect163k1"
    #define NID_sect163k1          721
    #define OBJ_sect163k1          OBJ_secg_ellipticCurve,1L 
    result for OpenSSL for generate keys is:
    private key: 202B
    public key: 43B
    sign: 42B r,s sequnce
    hash diggest: 20B
    sign exam:
    http://www.openssl.org/docs/crypto/ecdsa.html

    question is: How can I approve my verify and signature in javacard, what i will have to use? Can I use OpenSSL lib ? If yes which      algorithm I will have to use in OpenSSL when I use (ALG_EC_F2M, ALG_ECDSA_SHA) in java card ....

    Edited by: johny3212 on Sep 17, 2009 5:02 AM
  • 39. Re: Elliptic curve cryptography (ECC)
    Nara Newbie
    Currently Being Moderated
    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
  • 40. Re: Elliptic curve cryptography (ECC)
    PhHein Guru Moderator
    Currently Being Moderated
    Hi and welcome, Nara. Please don't hijack years old threads. Start your own and feel free to link relevant threads.

    Moderator action: I'm locking this thread now.
1 2 3 Previous Next