Java Code Examples for javacard.security.RSAPublicKey#getModulus()
The following examples show how to use
javacard.security.RSAPublicKey#getModulus() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IsoApplet.java From IsoApplet with GNU General Public License v3.0 | 6 votes |
/** * \brief Encode a 2048 bit RSAPublicKey according to ISO7816-8 table 3 and send it as a response, * using an extended APDU. * * \see ISO7816-8 table 3. * * \param apdu The apdu to answer. setOutgoing() must not be called already. * * \param key The RSAPublicKey to send. * Can be null for the secound part if there is no support for extended apdus. */ private void sendRSAPublicKey(APDU apdu, RSAPublicKey key) { short le = apdu.setOutgoing(); short pos = 0; ram_buf[pos++] = (byte) 0x7F; // Interindustry template for nesting one set of public key data objects. ram_buf[pos++] = (byte) 0x49; // " ram_buf[pos++] = (byte) 0x82; // Length field: 3 Bytes. ram_buf[pos++] = (byte) 0x01; // Length : 265 Bytes. ram_buf[pos++] = (byte) 0x09; // " ram_buf[pos++] = (byte) 0x81; // RSA public key modulus tag. ram_buf[pos++] = (byte) 0x82; // Length field: 3 Bytes. ram_buf[pos++] = (byte) 0x01; // Length: 256 bytes. ram_buf[pos++] = (byte) 0x00; // " pos += key.getModulus(ram_buf, pos); ram_buf[pos++] = (byte) 0x82; // RSA public key exponent tag. ram_buf[pos++] = (byte) 0x03; // Length: 3 Bytes. pos += key.getExponent(ram_buf, pos); sendLargeData(apdu, (short)0, pos); }
Example 2
Source File: GidsApplet.java From GidsApplet with GNU General Public License v3.0 | 5 votes |
/** * \brief Encode a 2048 bit RSAPublicKey according to ISO7816-8 table 3 and send it as a response, * using an extended APDU. * * \see ISO7816-8 table 3. * * \param apdu The apdu to answer. setOutgoing() must not be called already. * * \param key The RSAPublicKey to send. * Can be null for the secound part if there is no support for extended apdus. */ private void sendRSAPublicKey(APDU apdu, RSAPublicKey key) { short pos = 0; short size = key.getSize(); byte[] ram_buf = transmitManager.GetRamBuffer(); transmitManager.ClearRamBuffer(); ram_buf[pos++] = (byte) 0x7F; // Interindustry template for nesting one set of public key data objects. ram_buf[pos++] = (byte) 0x49; // " if (size < (short) 2048) { ram_buf[pos++] = (byte) 0x81; // Length field: 2 Bytes. ram_buf[pos++] = (byte) ((size / 8) + 8); } else { ram_buf[pos++] = (byte) 0x82; // Length field: 3 Bytes. Util.setShort(ram_buf, pos, (short)((size / 8) + 9)); pos += 2; } ram_buf[pos++] = (byte) 0x81; // RSA public key modulus tag. if (size < (short) 2048) { ram_buf[pos++] = (byte) 0x81; // Length field: 2 Bytes. ram_buf[pos++] = (byte) (size / 8); } else { ram_buf[pos++] = (byte) 0x82; // Length field: 3 Bytes. Util.setShort(ram_buf, pos, (short)(size / 8)); pos += 2; } pos += key.getModulus(ram_buf, pos); ram_buf[pos++] = (byte) 0x82; // RSA public key exponent tag. ram_buf[pos++] = (byte) 0x03; // Length: 3 Bytes. pos += key.getExponent(ram_buf, pos); transmitManager.sendDataFromRamBuffer(apdu, (short)0, pos); }