package mixconfig.tools.dataretention.smartcard; import mixconfig.tools.dataretention.smartcard.commands.AbstractCommand; import mixconfig.tools.dataretention.smartcard.commands.DataTransmissionCommand; import mixconfig.tools.dataretention.smartcard.commands.StartDataTransmissionCommand; import javacard.framework.ISO7816; public class ApduConstants { // MAIN INSTRUCTION CLASS /** * Class code for the ANONCardApplet class */ public final static byte CLA_ANON = (byte) 0xB0; // INSTRUCTIONS /** * The "this is no instruction" code. */ public static final byte INSTRUCTION_NOP = 0; /** * Instruction code for getVersion instruction. */ public final static byte INSTRUCTION_GET_VERSION = (byte) 0x20; /** * Instruction code for set number of needed admins. */ public final static byte INSTRUCTION_SET_NEEDED_NUMBER_OF_ADMINISTROTORS = (byte) 0x21; /** * Instruction code for starting a transaction. */ public static final byte INSTRUCTION_START_TRANSACTION = (byte) 0x22; /** * Instruction code for aborting a transaction. */ public static final byte INSTRUCTION_ABORT_TRANSACTION = (byte) 0x23; /** * Instruction code for committing a transaction. */ public static final byte INSTRUCTION_COMMIT_TRANSACTION = (byte) 0x24; /** * Instruction code for getting the flag, whether administrators can be * added/removed on this SmartCard. */ public static final byte INSTRUCTION_IS_ALLOWED_TO_MODIFY_ADMINISTRATORS = (byte) 0x25; /** * Instruction code for getting the flag, whether operators can be * added/removed on this SmartCard. */ public static final byte INSTRUCTION_IS_ALLOWED_TO_MODIFY_OPERATORS = (byte) 0x26; /** * Instruction code for getting the flag, whether time servers can be * added/removed on this SmartCard. */ public static final byte INSTRUCTION_IS_ALLOWED_TO_MODIFY_TIMESERVERS = (byte) 0x27; /** * Instruction code for getting the number of administrators. */ public static final byte INSTRUCTION_GET_NUMBER_OF_ADMINISTRATORS = (byte) 0x28; /** * Instruction code for getting the number of operators. */ public static final byte INSTRUCTION_GET_NUMBER_OF_OPERATORS = (byte) 0x29; /** * Instruction code for getting the name of an administrator. */ public static final byte INSTRUCTION_GET_NAME_OF_ADMINISTRATOR = (byte) 0x2A; /** * Instruction code for getting the name of an operator. */ public static final byte INSTRUCTION_GET_NAME_OF_OPERATOR = (byte) 0x2B; /** * Instruction code for getting the number of time servers. */ public static final byte INSTRUCTION_GET_NUMBER_OF_TIMESERVERS = (byte) 0x2C; /** * Instruction code for getting the domain of a time server. */ public static final byte INSTRUCTION_GET_NAME_OF_TIMESERVER = (byte) 0x2D; /** * Instruction code for setting, whether administrators, operators or time * servers can be added/removed later on. */ public static final byte INSTRUCTION_SET_PERMISSION_CHANGE_SETTINGS = (byte) 0x2E; /** * Instruction code for adding an administator. */ public static final byte INSTRUCTION_ADD_ADMINISTRATOR = (byte) 0x2F; /** * Instruction code to call operations, which need more than 255 byte * argument data. This instruction code must be used in the header (the * first) package. * * @see StartDataTransmissionCommand */ public static final byte INSTRUCTION_START_DATA_TRANSMISSION = (byte) 0x30; /** * Instruction code to call operations, which need more than 255 byte * argument data. This instruction code must be used in the data packages. * Any other instruction code will abort the current transmission without * performing the instruction, defined in the header package. * * @see StartDataTransmissionCommand */ public static final byte INSTRUCTION_DATA_TRANSMISSION = (byte) 0x31; /** * Instruction code for adding an operator. */ public static final byte INSTRUCTION_ADD_OPERATOR = (byte) 0x32; /** * Instruction code for set number of needed operators. */ public static final byte INSTRUCTION_SET_NEEDED_NUMBER_OF_OPERATORS = (byte) 0x33; /** * Instruction code for set changing the Pin of an existing administrator. */ public static final byte INSTRUCTION_CHANGE_ADMINISTRATOR_PIN = (byte) 0x34; /** * Instruction code for set changing the Pin of an existing operator. */ public static final byte INSTRUCTION_CHANGE_OPERATOR_PIN = (byte) 0x35; /** * Instruction code for removing an administrator. */ public static final byte INSTRUCTION_REMOVE_ADMINISTRATOR = (byte) 0x36; /** * Instruction code for removing an administrator. */ public static final byte INSTRUCTION_REMOVE_OPERATOR = (byte) 0x37; /** * Instruction code ask whether the ANONCardApplet is already initialized. */ public static final byte INSTRUCTION_IS_INITIALIZED = (byte) 0x38; /** * Instruction code to receive the next part of a longer response. */ public static final byte INSTRUCTION_GET_NEXT_DATA_PACKAGE = (byte) 0x39; /** * Instruction code to receive the public key later as long response. * * @see {@link #INSTRUCTION_GET_NEXT_DATA_PACKAGE} */ public static final byte INSTRUCTION_GET_PUBLIC_KEY = (byte) 0x3A; /** * Instruction code to receive the decrypted key later as long response. */ public static final byte INSTRUCTION_GET_SYMMETRIC_KEY_FOR_LOGFILES = (byte) 0x3B; /** * Instruction code to receive the size of the ANONCardApplet log. */ public static final byte INSTRUCTION_GET_ANONCARDAPPLET_LOG_SIZE = (byte) 0x3C; /** * Instruction code to reset the ANONCardApplet log file. */ public static final byte INSTRUCTION_RESET_ANONCARDAPPLET_LOG = (byte) 0x3D; /** * Instruction code to receive a entry of the ANONCardApplet log. */ public static final byte INSTRUCTION_GET_ANONCARDAPPLET_LOG_ENTRY = (byte) 0x3E; /** * Instruction code to get the needed number of administrator. */ public static final byte INSTRUCTION_GET_NEEDED_NUMBER_OF_ADMINISTRATORS = (byte) 0x3F; /** * Instruction code to get the needed number of administrator. */ public static final byte INSTRUCTION_GET_NEEDED_NUMBER_OF_OPERATORS = (byte) 0x40; /** * Instruction code to reset the ANONCardApplet. */ public static final byte INSTRUCTION_RESET_ANONCARDAPPLET_CARD = (byte) 0x41; /** * Instruction code to read the date. */ public static final byte INSTRUCTION_GET_DATE = (byte) 0x42; /** * Instruction code to set the date. */ public static final byte INSTRUCTION_SET_DATE = (byte) 0x43; /** * The AID of the ANON Applet. WARNING: Must be changed consistently in * several configuration files! */ public final static byte[] AID_ANON_APPLET = { (byte) 0x41, (byte) 0x4E, (byte) 0x4F, (byte) 0x4E, (byte) 0x4C, (byte) 0x6F, (byte) 0x67, (byte) 0x41, (byte) 0x70, (byte) 0x70, (byte) 0x6C, (byte) 0x65, (byte) 0x74, (byte) 0x02 }; /** * The number of digits a administrator pin has. */ public static final short LENGTH_OF_ADMINISTRATOR_PIN = 6; /** * The maximal number of characters, a administrator name can have. */ public static final short MAX_LENGTH_OF_ADMINISTRATOR_NAME = 127 - LENGTH_OF_ADMINISTRATOR_PIN; /** * The number of digits a operator pin has. */ public static final short LENGTH_OF_OPERATOR_PIN = 4; /** * The maximal number of characters, a operator name can have. */ public static final short MAX_LENGTH_OF_OPERATOR_NAME = 127 - LENGTH_OF_OPERATOR_PIN; /** * The Pin which can be send, to make the JavaCard to ask this Pin from the * keyboard if the Card reader. */ public static final String PIN_NOT_SET = "a"; // Exception code /** * Error Code for unsupported instruction codes. */ public static final short EXCEPTION_INS_NOT_SUPPORTED = ISO7816.SW_INS_NOT_SUPPORTED; /** * The current transmission is aborted, because the transmitted data is too * long (longer than specified in the StartDataTransmissionCommand). * * @see StartDataTransmissionCommand * @see DataTransmissionCommand */ public static final short EXCEPTION_DATA_TRANSMISSION_CHANNEL_DATA_OVERFLOW = 0x6501; /** * This shouldn't happen. * * @see StartDataTransmissionCommand * @see DataTransmissionCommand */ public static final short EXCEPTION_DATA_TRANMISSION_WAS_NOT_RESETED_NEITHER_EXECUTED = 0x6502; /** * This shouldn't happen. That means that the {@link AbstractCommand} * .arguments.length is greater than 127. * * @see StartDataTransmissionCommand * @see DataTransmissionCommand */ public static final short EXCEPTION_DATA_TRANSMISSION_ILLEGAL_LENGTH_ARGUMENT = 0x6503; /** * This Exception is thrown, if a operation is performed without enough * valid admin logins. * */ public static final short EXCEPTION_ADMIN_PERMISSION_DENIED = 0x6504; /** * Thrown, if the configuration of the card is tried to change, but no * transaction is in progress. */ public static final short EXCEPTION_NO_OPEN_TRANSACTION = 0x6505; /** * @see IllegalArgumentException */ public static final short EXCEPTION_ILLEGAL_ARGUMENT = 0x6506; /** * TODO: better name */ public static final short EXCEPTION_OAEP_DECODE_FAIL = 0x6507; /** * The JavaCard received a DataTransmissionCommand with a Data Package, but * has received no StartDataTransmissionCommand (or the transmission was * already aborted). * * @see StartDataTransmissionCommand * @see DataTransmissionCommand */ public static final short EXCEPTION_DATA_TRANSMISSION_CHANNEL_IS_CLOSED = 0x6508; /** * Thrown, if a operation is called, which can only be performed on * initialization, if the applet has been already initialized. */ public static final short EXCEPTION_APPLET_ALREADY_INITIALIZED = 0x6509; /** * Thrown, if a operation is called, which is not be called any more (due to * the applets configuration). */ public static final short EXCEPTION_ILLEGAL_OPERATION = 0x650A; /** * Thrown, if a add* is called and the card already exceeded the maximal * number of those items. */ public static final short EXCEPTION_TO_MANY = 0x650B; /** * Thrown, iff a operation is performed, which is to be logged, but the log * is already full. */ public static final short EXCEPTION_ANONCARDAPPLET_LOG_IS_FULL = 0x650C; /** * Thrown, if operator login fails. */ public static final short EXCEPTION_OPERATOR_PERMISSION_DENIED = 0x650D; /** * Thrown, if the ANONCardApplet does not know the current date, but needs * it. */ public static final short EXCEPTION_DATE_NOT_SET = 0x650E; /** * Thrown, if a symmetric key is tried to be decrypted, which is older than * {@link #DATA_RETENTION_PERIOD_IN_MONTHS} months. */ public static final short EXCEPTION_OUTDATED_KEY = 0x650F; /** * The first byte of the response data for an package ack. */ public static final byte DATA_TRANSMISSION_PACKAGE_ACK_MAJOR = (byte) 0x60; /** * The second (and last) byte of the response data for an package ack. */ public static final byte DATA_TRANSMISSION_PACKAGE_ACK_MINOR = (byte) 0xFA; /** * A byte which means true. */ public static final byte TRUE = (byte) 0x12; /** * A byte which means false. */ public static final byte FALSE = (byte) 0x43; /** * The maximal number of administrators on the smart card. */ public static final byte MAXIMAL_NUMBER_OF_ADMINISTRATORS = 12; /** * The maximal number of operators on the smart card. */ public static final byte MAXIMAL_NUMBER_OF_OPERATORS = 12; /** * The maximal number of time servers on the smart card. */ public static final byte MAXIMAL_NUMBER_OF_TIMESERVERS = 12; /** * The maximal number of months, the ANONCardApplet decrypts symmetric keys. */ public static final byte DATA_RETENTION_PERIOD_IN_MONTHS = 6; /** * The maximal number of log entries saved on the card. */ public static final short MAXIMAL_SIZE_OF_ANONCARDAPPLET_LOG = 300; }