This discussion is archived
7 Replies Latest reply: Aug 2, 2012 10:59 AM by safarmer RSS

KeyPair memory consumption

864549 Newbie
Currently Being Moderated
Dear all,

anyone able to tell me the memory consumption of following call:
new KeyPair(KeyPair.ALG_RSA_CRT, (short) 2048);
Phil
  • 1. Re: KeyPair memory consumption
    safarmer Expert
    Currently Being Moderated
    Hi,

    Counting off the top of my head: 5 CRT components @ 128 bytes (half the modulus size), a public exponent @ 4 bytes and a modulus @ 256 bytes

    An example from Java SE with the bits removed JC does not have (Java SE private key contains the public key as well as both a normal and CRT private key):
    Sun RSA private CRT key, 2048 bits
      modulus:          26757631189637327696056797174165311470568997599469189125139795397518482329882357588743486073358499254949456098948686851519313525997680001303623269747428786165481294565389733851976454872191332099707809046286781310606688248189913652457996553271161769440497390854003351696910548177886688688855127616703392896754316632424604273253184833442713287040225766620656220248559459406709374287728748388757263882425508162926526516757886993892587488532430202815311742322278791222446962530788280187758784617114395246453843201106979826605489119214348337003467296734623403988768556030792648921288599314357142887476599216463908318842693
      public exponent:  65537
      prime p:          173539553585720393798400324637437416850022185442875422388309037120211714670952674440111689290206121617361916753101549581629918310471485153565536232121880073201475586956857574251604482457155540684429488732731060608848287835910979190590018063305462574897444179258322801501821317215599610142969074433308201960541
      prime q:          154187507324780075853905631549622708802622457131906349207537046224694102443026368433346622730860341735569253744173175474493139759317262671532094938138119056153658335182573976951271669376779132558521328572860693086798798881384887490981967228674493031682900437392601451500335695465748203531050033327964805515273
      prime exponent p: 86315651131936580506377395703290469155746725954520502061304449135717858051620372136721557834396584316663051412192367848885216704555274143625368639981642808583677917939983312447618159431403621766183194900908408725859096977084550539018612673902805492377313394132834099219599149751695996030186961858225848899213
      prime exponent q: 11648112497749151708999294777029495266517902639120929168660694201114797766077537118169875477066230555759393553067753967594115308121820765167087325308174427377157367860733993925351267758433152040789769103929586210426794837446580984296683091218203686465081405397420842979967987980086353596933468346228142150329
      crt coefficient:  77494508659478675099808485384783738875894588631476569470449436044698273272517302107896274777688777973675399318226662269210918052171027000823429429064523446895480323127741128267925254097168608643874626461357265232702794285514430851494549237360046429534915764916270428934291279509920405129134544393593784644264
    Cheers,
    Shane
  • 2. Re: KeyPair memory consumption
    864549 Newbie
    Currently Being Moderated
    Dear Shane, thanks a lot for your hint. Much appreciated!
  • 3. Re: KeyPair memory consumption
    864549 Newbie
    Currently Being Moderated
    How is the public key part treated?
    Does it always go to permanent storage, or does it never go to permanent storage?

    Both parts (private/public keys) are created at key generation, but what is left afterwards in storage is the interesting question.

    Does anybody know ?
  • 4. Re: KeyPair memory consumption
    816119 Journeyer
    Currently Being Moderated
    all keys are left...
    what makes you think that public key disappears?

    Edited by: 666 on 31.07.2012 7:12
  • 5. Re: KeyPair memory consumption
    safarmer Expert
    Currently Being Moderated
    Even if part of the key were discarded, it is safe to assume that the storage remains so that if you regenerate the key pair there is room to store the result.

    Shane
  • 6. Re: KeyPair memory consumption
    864549 Newbie
    Currently Being Moderated
    A Java Card doesn't usually need a public key for its private key afterwards the key has been generated (Just once during the keygen). That's why the question came up.

    Thank you for the help!
  • 7. Re: KeyPair memory consumption
    safarmer Expert
    Currently Being Moderated
    oyfen wrote:
    A Java Card doesn't usually need a public key for its private key afterwards the key has been generated (Just once during the keygen). That's why the question came up.
    You still need the key. A key pair is useless without both keys. You don't usually use it as a key object, but you still need to store it somewhere.

    Shane

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points