title: Java Card 2.2.2: temporary RSA public key as transient
body: <p>I'm designing a Java Card (2.2.2 thus Classic) applet that will, at each use, receive a RSA public key (validated using means immaterial to the question), then use that RSA public key to verify an RSA signature.</p>
  
  <p>How can I keep that RSA public key in RAM (rather than writing it in EEPROM/Flash), for performance and device lifetime reasons ?</p>
  
  <p>My problem is, in <code>javacard.security.KeyBuilder</code> of JC 2.2.2, the <a href="https://docs.oracle.com/javacard/3.0.5/api/javacard/security/KeyBuilder.html#buildKey%28byte,%20short,%20boolean%29" rel="nofollow"><code>buildKey(byte keyType, short keyLength, boolean keyEncryption)</code></a> API does not seem to have an option to specify transient memory; I see neither</p>
  
  <ul>
  <li>a suitable <code>keyType</code> combining <code>TYPE_RSA_PUBLIC</code> and transcient, as we have with <a href="https://docs.oracle.com/javacard/3.0.5/api/javacard/security/KeyBuilder.html#TYPE_DES_TRANSIENT_DESELECT" rel="nofollow"><code>TYPE_DES_TRANSIENT_DESELECT</code></a>;</li>
  <li>not even <a href="https://docs.oracle.com/javacard/3.0.5/api/javacard/security/KeyBuilder.html#TYPE_RSA_PRIVATE_TRANSIENT_DESELECT" rel="nofollow"><code>TYPE_RSA_PRIVATE_TRANSIENT_DESELECT</code></a> which conceivably could be abused into a public key (on platforms with no test for the size of <em>d</em>), for this is a novelty of Java Card Classic 3;</li>
  <li>the <a href="https://docs.oracle.com/javacard/3.0.5/api/javacard/security/KeyBuilder.html#buildKey%28byte,%20byte,%20short,%20boolean%29" rel="nofollow"><code>buildKey(byte algorithmicKeyType, byte keyMemoryType, short keyLength, boolean keyEncryption)</code></a> with a <code>keyMemoryType</code>parameter, which also is a novelty of Java Card Classic 3.</li>
  </ul>
  
  <p>Would bracketing all changes and uses of my RSA public key with <code>beginTransaction()</code> and <code>abortTransaction()</code> achieve my goal?</p>