3 Replies Latest reply: Nov 12, 2010 2:12 AM by safarmer RSS

    RSA Performance with key length 768 and 1024

    811808
      Hi,

      I have made a RSA Encryption testa with keys that have length 768 and 1024.
      I have seen in debuggin window, ~4000 us for 768, ~3000 us for 1024 length key.

      For other keys the time duration increases arithmeticaly(512..1984). But for these keys...

      Does anyone have any idea,


      private final static short RSA_KEY_SIZE                    =     KeyBuilder.LENGTH_RSA_768;
      ...
      rsa_KeyPair               =     new KeyPair(KeyPair.ALG_RSA_CRT, RSA_KEY_SIZE);
      ...
                cipherRSA               =     Cipher.getInstance(Cipher.ALG_RSA_NOPAD, false);

      cipherRSA.init(rsa_PrivateCrtKey, Cipher.MODE_ENCRYPT);
                short cyphertext     =     cipherRSA.doFinal(inpBuffer,(short) 0, (short) (RSA_KEY_SIZE/8), buf, ISO7816.OFFSET_CDATA);

      thank you.
        • 1. Re: RSA Performance with key length 768 and 1024
          safarmer
          Hi,

          Are you referring to performance on a card? Is the time you mention when debugging calls to a real card from the host application or stepping through code on a simulator?

          Most cards will have a dedicated crypto chip that is dedicated hardware for RSA operations. If you are using PKCS1 padding, there is a random nunmber generation involved that could have variable execution time. You should really perform several operations and average out the result to get an accurate answer.

          Here is the results from doing a speed test with RSA on my PC. As you can see it performs multiple operations over a period of time to see how many can be performed per second.
          $ openssl speed rsa
          Doing 512 bit private rsa's for 10s: 22820 512 bit private RSA's in 9.95s
          Doing 512 bit public rsa's for 10s: 287768 512 bit public RSA's in 9.97s
          Doing 1024 bit private rsa's for 10s: 5259 1024 bit private RSA's in 9.89s
          Doing 1024 bit public rsa's for 10s: 116357 1024 bit public RSA's in 9.86s
          Doing 2048 bit private rsa's for 10s: 978 2048 bit private RSA's in 9.83s
          Doing 2048 bit public rsa's for 10s: 39057 2048 bit public RSA's in 9.86s
          Doing 4096 bit private rsa's for 10s: 162 4096 bit private RSA's in 9.91s
          Doing 4096 bit public rsa's for 10s: 11922 4096 bit public RSA's in 9.88s
          OpenSSL 0.9.8k 25 Mar 2009
          
                            sign    verify    sign/s verify/s
          rsa  512 bits 0.000436s 0.000035s   2292.8  28869.2
          rsa 1024 bits 0.001881s 0.000085s    531.7  11802.1
          rsa 2048 bits 0.010049s 0.000252s     99.5   3961.6
          rsa 4096 bits 0.061148s 0.000828s     16.4   1207.3
          Cheers,
          Shane
          • 2. Re: RSA Performance with key length 768 and 1024
            811808
            Thank you shane,

            Actually i need to find difference of duration on card, for different lenght of key.
            Before i do that, i made some test on jcop shell, the values that are written in previous mail are taken from simulator screen.

            I couldnt see in your test results with key lenght 768. This length is actually important for me, it is used on contactless EMV cards.

            Also i am working with mode ALG_RSA_NOPAD. I put some part of the code, you can check...

            Thank you.
            • 3. Re: RSA Performance with key length 768 and 1024
              safarmer
              simeranya wrote:
              Actually i need to find difference of duration on card, for different lenght of key.
              That was an example of the difference in complexity of different key lengths. The principal should transfer to a smart card as well.
              Before i do that, i made some test on jcop shell, the values that are written in previous mail are taken from simulator screen.
              Then those times are for performing the crypto operation on your PC processor so is not a reasonable example either. You need to run this against a real card to find out how your code and card performs.
              I couldnt see in your test results with key lenght 768. This length is actually important for me, it is used on contactless EMV cards.
              Once again, just an example of differences for illustration.
              Also i am working with mode ALG_RSA_NOPAD. I put some part of the code, you can check...
              As for your code, private keys are used for decryption. Public keys are used for encryption.

              Cheers,
              Shane