pteidlib
Class pteid

java.lang.Object
  extended by pteidlib.pteid

public class pteid
extends java.lang.Object


Field Summary
static int ADDR_CANCELLED
           
static int ADDR_CLIENT_AUTH
           
static int ADDR_CONNECTING
           
static int ADDR_FINISH
           
static int ADDR_FINISHED
           
static int ADDR_INIT_SEC_CHANNEL
           
static int ADDR_INITIALISING
           
static int ADDR_READING_INFO
           
static int ADDR_SENDING_INFO
           
static int ADDR_SERVER_AUTH
           
static int ADDR_SERVER_AUTH2
           
static int ADDR_SERVER_CHALL
           
static int ADDR_WRITE
           
static int CAP_CANCELLED
           
static int CAP_CONNECTING
           
static int CAP_FINISH
           
static int CAP_FINISHED
           
static int CAP_INITIALISING
           
static int CAP_READING_INFO
           
static int CAP_SENDING_INFO
           
static int CAP_WRITE
           
static int CARD_TYPE_ERR
           
static int CARD_TYPE_IAS07
           
static int CARD_TYPE_IAS101
           
static int CVC_WRITE_MODE_PAD
           
static int MODE_ACTIVATE_BLOCK_PIN
           
static int PTEID_EXIT_LEAVE_CARD
           
static int PTEID_EXIT_UNPOWER
           
static int UNBLOCK_FLAG_NEW_PIN
           
static int UNBLOCK_FLAG_PUK_MERGE
           
static int WEB_ERR_BAD_COMMAND
           
static int WEB_ERR_CARD_COMM
           
static int WEB_ERR_CARD_REMOVED
           
static int WEB_ERR_DATA_SIZE
           
static int WEB_ERR_EMPTY_RES
           
static int WEB_ERR_INTERNAL
           
static int WEB_ERR_INVALID_HASH
           
static int WEB_ERR_MISSING_DATA
           
static int WEB_ERR_OK
           
static int WEB_ERR_OUT_OF_MEM
           
static int WEB_ERR_PARSING
           
static int WEB_ERR_READ_FILE
           
static int WEB_ERR_SELECT_FILE
           
static int WEB_ERR_WRITE_FILE
           
 
Constructor Summary
pteid()
           
 
Method Summary
static void Activate(java.lang.String pin, byte[] date, int mode)
          Activate the card (= update a specific file on the card).
static void CancelChangeAddress()
          Allows the library user to cancel a running Change Address operation.
static void CAP_CancelCapPinChange()
          Allows the library user to cancel a running Change CAP PIN operation.
static long CAP_ChangeCapPin(java.lang.String server, byte[] serverCaCert, PTEID_Proxy_Info proxyInfo, java.lang.String oldPIN, java.lang.String newPIN)
          Do a CAP PIN change, this function will connect the CAP PIN Change Server and forward commands between the Card and the CAP PIN Server.
static int CAP_GetCapPinChangeProgress()
          Returns info on what the ChangeCapPin() is currently doing: CAP_INITIALISING, CAP_CONNECTING, ...
static void ChangeAddress(java.lang.String server, byte[] serverCaCert, PTEID_Proxy_Info proxyInfo, java.lang.String secretCode, java.lang.String processCode)
          Do an address change, this function will connect the Address Change Server and forward commands between the Card and the Address Change Server.
static int ChangePIN(byte pinId, java.lang.String oldPin, java.lang.String newPin)
           
static byte[] CVC_Authenticate_SM101(byte[] signedChallenge, byte[] ifdSerialNr, byte[] iccSerialNr, byte[] keyIfd, byte[] encKey, byte[] macKey)
          Only for IAS 1.0.1 cards, 2nd command to be executed starting a secure session using symmetric keys.
static void CVC_Authenticate(byte[] signedChallenge)
          Finish the CVC authentication with the card, to be called after a CVC_Init() Parameters: signedChallenge: (IN) the challenge that was signed by the private key corresponding to the CVC
static PTEID_ADDR CVC_GetAddr()
          Read the address file over a 'CVC channel' and put the contents into a PTEID_ADDR class.
static byte[] CVC_Init_SM101()
          Only for IAS 1.0.1 cards, 1st to be executed starting a secure session using symmetric keys.
static byte[] CVC_Init(byte[] cert)
          Start a CVC authentication with the card.
static PTEID_DH_Auth_Response CVC_R_DH_Auth(byte[] Kidf, byte[] cvcCert)
          Complete the DH key agreement and ask the card for a challenge.
static PTEID_DH_Params CVC_R_Init()
          Get the DH parameters, to be sent to the Server
static void CVC_R_ValidateSignature(byte[] signedChallenge)
          Provide the signed challenge (made by the Server)to the card.
static byte[] CVC_ReadFile(byte[] file)
          Read out the contents of a file over a 'CVC channel'.
static void CVC_WriteAddr(PTEID_ADDR addr)
          Write to the address file over a 'CVC channel' A successfull CVC_Init() and CVC_Authenticate() must have been done before.
static void CVC_WriteFile(byte[] file, int fileOffset, byte[] in, int mode)
          Write to a file on the card over a 'CVC channel'.
static void CVC_WriteSOD(int fileOffset, byte[] in, int mode)
          This function calls CVC_WriteFile() with the SOD file as path.
static void Exit(int mode)
           
static PTEID_ADDR GetAddr()
           
static int GetCardType()
           
static PTEID_Certif[] GetCertificates()
           
static int GetChangeAddressProgress()
          Returns info on what the ChangeAddress() is currently doing: ADDR_INITIALISING, ADDR_CONNECTING, ...
static PTEID_RSAPublicKey GetCVCRoot()
          Get the CVC CA public key that this card uses to verify the CVC key; allowing the application to select the correct CVC certificate for this card.
static PTEID_ID GetID()
           
static int GetLastWebErrorCode()
          Returns the latest error code received or sent by Change Address or CAP PIN change.
static java.lang.String GetLastWebErrorMessage()
          Returns the lastest error message received or sent by Change Address or CAP PIN change.
static PTEID_PIC GetPic()
           
static PTEID_Pin[] GetPINs()
           
static PTEID_TokenInfo GetTokenInfo()
           
static void Init(java.lang.String readerName)
           
static int IsActivated()
          Get the activation status of the card.
static byte[] ReadFile(byte[] file, byte pinId)
           
static byte[] ReadSOD()
          This function calls ReadFile() with the SOD file as path.
static void SelectADF(byte[] adf)
           
static byte[] SendAPDU(byte[] request)
          Send an APDU to the card, see ISO7816-4 for more info
static void SetSODCAs(PTEID_Certif[] certifs)
          Specify the (root) certificates that are used to sign the DocumentSigner certificates in the SOD file.
static void SetSODChecking(boolean check)
          Turn on/off SOD checking.
static int UnblockPIN_Ext(byte pinId, java.lang.String puk, java.lang.String newPin, int flags)
          Extended Unblock PIN function: Values for ulFlags: - UNBLOCK_FLAG_NEW_PIN - UNBLOCK_FLAG_PUK_MERGE E.g. calling UnblockPIN_Ext() with flags = UNBLOCK_FLAG_NEW_PIN is the same as calling UnblockPIN(...)
static int UnblockPIN(byte pinId, java.lang.String puk, java.lang.String newPin)
          Unblock PIN with PIN change: If puk == null or newPin == null, a GUI is shown asking for the PUK and the new PIN
static int VerifyPIN(byte pinId, java.lang.String pin)
           
static void WriteFile(byte[] file, byte[] in, byte pinId)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PTEID_EXIT_LEAVE_CARD

public static final int PTEID_EXIT_LEAVE_CARD
See Also:
Constant Field Values

PTEID_EXIT_UNPOWER

public static final int PTEID_EXIT_UNPOWER
See Also:
Constant Field Values

UNBLOCK_FLAG_NEW_PIN

public static final int UNBLOCK_FLAG_NEW_PIN
See Also:
Constant Field Values

UNBLOCK_FLAG_PUK_MERGE

public static final int UNBLOCK_FLAG_PUK_MERGE
See Also:
Constant Field Values

MODE_ACTIVATE_BLOCK_PIN

public static final int MODE_ACTIVATE_BLOCK_PIN
See Also:
Constant Field Values

CVC_WRITE_MODE_PAD

public static final int CVC_WRITE_MODE_PAD
See Also:
Constant Field Values

CARD_TYPE_ERR

public static final int CARD_TYPE_ERR
See Also:
Constant Field Values

CARD_TYPE_IAS07

public static final int CARD_TYPE_IAS07
See Also:
Constant Field Values

CARD_TYPE_IAS101

public static final int CARD_TYPE_IAS101
See Also:
Constant Field Values

ADDR_INITIALISING

public static final int ADDR_INITIALISING
See Also:
Constant Field Values

ADDR_CONNECTING

public static final int ADDR_CONNECTING
See Also:
Constant Field Values

ADDR_READING_INFO

public static final int ADDR_READING_INFO
See Also:
Constant Field Values

ADDR_SENDING_INFO

public static final int ADDR_SENDING_INFO
See Also:
Constant Field Values

ADDR_INIT_SEC_CHANNEL

public static final int ADDR_INIT_SEC_CHANNEL
See Also:
Constant Field Values

ADDR_SERVER_CHALL

public static final int ADDR_SERVER_CHALL
See Also:
Constant Field Values

ADDR_SERVER_AUTH

public static final int ADDR_SERVER_AUTH
See Also:
Constant Field Values

ADDR_CLIENT_AUTH

public static final int ADDR_CLIENT_AUTH
See Also:
Constant Field Values

ADDR_SERVER_AUTH2

public static final int ADDR_SERVER_AUTH2
See Also:
Constant Field Values

ADDR_WRITE

public static final int ADDR_WRITE
See Also:
Constant Field Values

ADDR_FINISH

public static final int ADDR_FINISH
See Also:
Constant Field Values

ADDR_FINISHED

public static final int ADDR_FINISHED
See Also:
Constant Field Values

ADDR_CANCELLED

public static final int ADDR_CANCELLED
See Also:
Constant Field Values

CAP_INITIALISING

public static final int CAP_INITIALISING
See Also:
Constant Field Values

CAP_CONNECTING

public static final int CAP_CONNECTING
See Also:
Constant Field Values

CAP_READING_INFO

public static final int CAP_READING_INFO
See Also:
Constant Field Values

CAP_SENDING_INFO

public static final int CAP_SENDING_INFO
See Also:
Constant Field Values

CAP_WRITE

public static final int CAP_WRITE
See Also:
Constant Field Values

CAP_FINISH

public static final int CAP_FINISH
See Also:
Constant Field Values

CAP_FINISHED

public static final int CAP_FINISHED
See Also:
Constant Field Values

CAP_CANCELLED

public static final int CAP_CANCELLED
See Also:
Constant Field Values

WEB_ERR_OK

public static final int WEB_ERR_OK
See Also:
Constant Field Values

WEB_ERR_SELECT_FILE

public static final int WEB_ERR_SELECT_FILE
See Also:
Constant Field Values

WEB_ERR_READ_FILE

public static final int WEB_ERR_READ_FILE
See Also:
Constant Field Values

WEB_ERR_WRITE_FILE

public static final int WEB_ERR_WRITE_FILE
See Also:
Constant Field Values

WEB_ERR_BAD_COMMAND

public static final int WEB_ERR_BAD_COMMAND
See Also:
Constant Field Values

WEB_ERR_EMPTY_RES

public static final int WEB_ERR_EMPTY_RES
See Also:
Constant Field Values

WEB_ERR_DATA_SIZE

public static final int WEB_ERR_DATA_SIZE
See Also:
Constant Field Values

WEB_ERR_CARD_REMOVED

public static final int WEB_ERR_CARD_REMOVED
See Also:
Constant Field Values

WEB_ERR_CARD_COMM

public static final int WEB_ERR_CARD_COMM
See Also:
Constant Field Values

WEB_ERR_OUT_OF_MEM

public static final int WEB_ERR_OUT_OF_MEM
See Also:
Constant Field Values

WEB_ERR_INTERNAL

public static final int WEB_ERR_INTERNAL
See Also:
Constant Field Values

WEB_ERR_PARSING

public static final int WEB_ERR_PARSING
See Also:
Constant Field Values

WEB_ERR_MISSING_DATA

public static final int WEB_ERR_MISSING_DATA
See Also:
Constant Field Values

WEB_ERR_INVALID_HASH

public static final int WEB_ERR_INVALID_HASH
See Also:
Constant Field Values
Constructor Detail

pteid

public pteid()
Method Detail

Init

public static void Init(java.lang.String readerName)
                 throws PteidException
Throws:
PteidException

Exit

public static void Exit(int mode)
                 throws PteidException
Throws:
PteidException

GetCardType

public static int GetCardType()
                       throws PteidException
Throws:
PteidException

GetID

public static PTEID_ID GetID()
                      throws PteidException
Throws:
PteidException

GetAddr

public static PTEID_ADDR GetAddr()
                          throws PteidException
Throws:
PteidException

GetPic

public static PTEID_PIC GetPic()
                        throws PteidException
Throws:
PteidException

GetCertificates

public static PTEID_Certif[] GetCertificates()
                                      throws PteidException
Throws:
PteidException

VerifyPIN

public static int VerifyPIN(byte pinId,
                            java.lang.String pin)
                     throws PteidException
Throws:
PteidException

ChangePIN

public static int ChangePIN(byte pinId,
                            java.lang.String oldPin,
                            java.lang.String newPin)
                     throws PteidException
Throws:
PteidException

GetPINs

public static PTEID_Pin[] GetPINs()
                           throws PteidException
Throws:
PteidException

GetTokenInfo

public static PTEID_TokenInfo GetTokenInfo()
                                    throws PteidException
Throws:
PteidException

ReadSOD

public static byte[] ReadSOD()
                      throws PteidException
This function calls ReadFile() with the SOD file as path.

Throws:
PteidException

UnblockPIN

public static int UnblockPIN(byte pinId,
                             java.lang.String puk,
                             java.lang.String newPin)
                      throws PteidException
Unblock PIN with PIN change: If puk == null or newPin == null, a GUI is shown asking for the PUK and the new PIN

Throws:
PteidException

UnblockPIN_Ext

public static int UnblockPIN_Ext(byte pinId,
                                 java.lang.String puk,
                                 java.lang.String newPin,
                                 int flags)
                          throws PteidException
Extended Unblock PIN function: Values for ulFlags: - UNBLOCK_FLAG_NEW_PIN - UNBLOCK_FLAG_PUK_MERGE E.g. calling UnblockPIN_Ext() with flags = UNBLOCK_FLAG_NEW_PIN is the same as calling UnblockPIN(...)

Throws:
PteidException

SelectADF

public static void SelectADF(byte[] adf)
                      throws PteidException
Throws:
PteidException

ReadFile

public static byte[] ReadFile(byte[] file,
                              byte pinId)
                       throws PteidException
Throws:
PteidException

WriteFile

public static void WriteFile(byte[] file,
                             byte[] in,
                             byte pinId)
                      throws PteidException
Throws:
PteidException

IsActivated

public static int IsActivated()
                       throws PteidException
Get the activation status of the card. After successfull return: - if status == 0, the card is not activated - if status == 1, the card is not activated

Throws:
PteidException

Activate

public static void Activate(java.lang.String pin,
                            byte[] date,
                            int mode)
                     throws PteidException
Activate the card (= update a specific file on the card). Parameters: pin: the value of the Activation PIN date: the current date in DD MM YY YY format in BCD format (4 bytes), e.g. {0x17 0x11 0x20 0x06} for the 17th of Nov. 2006) mode: set to MODE_ACTIVATE_BLOCK_PIN to block the Activation PIN, or to 0 otherwise.

Throws:
PteidException

SetSODChecking

public static void SetSODChecking(boolean check)
                           throws PteidException
Turn on/off SOD checking. 'SOD' checking means that the validity of the ID data, address data, the photo and the card authentication public key is checked to ensure it is not forged. This is done by reading the SOD file which contains hashes over the above data and is signed by a DocumentSigner certificate.

Throws:
PteidException

SetSODCAs

public static void SetSODCAs(PTEID_Certif[] certifs)
                      throws PteidException
Specify the (root) certificates that are used to sign the DocumentSigner certificates in the SOD file. (The SOD file in the card is signed by a Document Signer cert, and this cert is inside the SOD as well). This library contains a hard-coded certificate, so as long as the DocumentSigner cert on all cards is signed by the root cert, there is no need to call this function. For performance reasons, the certificates are not copied internally. This means that the application must ensure that the certificates structs remain valid for as long as the library is used, or until this funtion is called with another value, or NULL.

Throws:
PteidException

GetCVCRoot

public static PTEID_RSAPublicKey GetCVCRoot()
                                     throws PteidException
Get the CVC CA public key that this card uses to verify the CVC key; allowing the application to select the correct CVC certificate for this card.

Throws:
PteidException

CVC_Init

public static byte[] CVC_Init(byte[] cert)
                       throws PteidException
Start a CVC authentication with the card. The resuling challenge should be signed with the private key corresponding to the CVC certificate (raw RSA signature) and provided in the CVC_Authenticate() function.

Throws:
PteidException

CVC_Authenticate

public static void CVC_Authenticate(byte[] signedChallenge)
                             throws PteidException
Finish the CVC authentication with the card, to be called after a CVC_Init() Parameters: signedChallenge: (IN) the challenge that was signed by the private key corresponding to the CVC

Throws:
PteidException

CVC_Init_SM101

public static byte[] CVC_Init_SM101()
                             throws PteidException
Only for IAS 1.0.1 cards, 1st to be executed starting a secure session using symmetric keys. Returns the challenge to be signed

Throws:
PteidException

CVC_Authenticate_SM101

public static byte[] CVC_Authenticate_SM101(byte[] signedChallenge,
                                            byte[] ifdSerialNr,
                                            byte[] iccSerialNr,
                                            byte[] keyIfd,
                                            byte[] encKey,
                                            byte[] macKey)
Only for IAS 1.0.1 cards, 2nd command to be executed starting a secure session using symmetric keys. Parameters: signedChallenge: (IN) the challenge that was signed by the derived symmetric key ifdSerialNr: (IN) the serial number of the terminal iccSerialNr: (IN) the serial number of the card keyIdf: (IN) secret key kIDF, generated by the terminal encKey: (IN) the derived encoding key for mutual authentication macKey: (IN) the derived Mac key for mutual authentication Returns the response from the card to the authentication


CVC_ReadFile

public static byte[] CVC_ReadFile(byte[] file)
                           throws PteidException
Read out the contents of a file over a 'CVC channel'. A successfull CVC_Init() and CVC_Authenticate() must have been done before.

Throws:
PteidException

CVC_WriteFile

public static void CVC_WriteFile(byte[] file,
                                 int fileOffset,
                                 byte[] in,
                                 int mode)
                          throws PteidException
Write to a file on the card over a 'CVC channel'. A successfull CVC_Init() and CVC_Authenticate() must have been done before.

Throws:
PteidException

CVC_GetAddr

public static PTEID_ADDR CVC_GetAddr()
Read the address file over a 'CVC channel' and put the contents into a PTEID_ADDR class. A successfull CVC_Init() and CVC_Authenticate() must have been done before.


CVC_WriteAddr

public static void CVC_WriteAddr(PTEID_ADDR addr)
                          throws PteidException
Write to the address file over a 'CVC channel' A successfull CVC_Init() and CVC_Authenticate() must have been done before. Remark: the address data will be padded with 0 bytes up to the length of the address file.

Throws:
PteidException

CVC_WriteSOD

public static void CVC_WriteSOD(int fileOffset,
                                byte[] in,
                                int mode)
                         throws PteidException
This function calls CVC_WriteFile() with the SOD file as path.

Throws:
PteidException

CVC_R_Init

public static PTEID_DH_Params CVC_R_Init()
Get the DH parameters, to be sent to the Server


CVC_R_DH_Auth

public static PTEID_DH_Auth_Response CVC_R_DH_Auth(byte[] Kidf,
                                                   byte[] cvcCert)
Complete the DH key agreement and ask the card for a challenge. More in detail, the following is done: - Check the CVC cert (pucCert) by means of the CA pubkey on the card - Send Kifd (received from the Server) to the card - Read out Kicc, should be sent to the Server - Send the CVC cert to the card for verification - Tell the card to use the public key in the CVC cert - Ask a challenge to the card, should be sent to the Server


CVC_R_ValidateSignature

public static void CVC_R_ValidateSignature(byte[] signedChallenge)
Provide the signed challenge (made by the Server)to the card.


SendAPDU

public static byte[] SendAPDU(byte[] request)
Send an APDU to the card, see ISO7816-4 for more info. - For a case 1 APDU: request.length should be 4 - For a case 2 APDU: request.length should be 5 - For a case 3 APDU: ucRequest[4] + 5 should equal request.length - For a case 4 APDU: ucRequest[4] + 5 should equal request.length + 1, the last byte is the 'Le' value If the call has been successfull, the response should always contain SW1 and SW2 at the end.


ChangeAddress

public static void ChangeAddress(java.lang.String server,
                                 byte[] serverCaCert,
                                 PTEID_Proxy_Info proxyInfo,
                                 java.lang.String secretCode,
                                 java.lang.String processCode)
Do an address change, this function will connect the Address Change Server and forward commands between the Card and the Address Change Server. Parameters: - server: Change Server, format: : - serverCaCert: the server's CA certificate - proxy info, or null if no proxy is needed - secretCode: the Secret code that the citizen received - processCode: the Process code that the citizen received


GetChangeAddressProgress

public static int GetChangeAddressProgress()
Returns info on what the ChangeAddress() is currently doing: ADDR_INITIALISING, ADDR_CONNECTING, ...


CancelChangeAddress

public static void CancelChangeAddress()
Allows the library user to cancel a running Change Address operation.


CAP_ChangeCapPin

public static long CAP_ChangeCapPin(java.lang.String server,
                                    byte[] serverCaCert,
                                    PTEID_Proxy_Info proxyInfo,
                                    java.lang.String oldPIN,
                                    java.lang.String newPIN)
Do a CAP PIN change, this function will connect the CAP PIN Change Server and forward commands between the Card and the CAP PIN Server. Parameters: - server: Change Server, format: : - serverCaCert: the server's CA certificate - proxy info, or null if no proxy is needed


CAP_GetCapPinChangeProgress

public static int CAP_GetCapPinChangeProgress()
Returns info on what the ChangeCapPin() is currently doing: CAP_INITIALISING, CAP_CONNECTING, ...


CAP_CancelCapPinChange

public static void CAP_CancelCapPinChange()
Allows the library user to cancel a running Change CAP PIN operation.


GetLastWebErrorCode

public static int GetLastWebErrorCode()
Returns the latest error code received or sent by Change Address or CAP PIN change.


GetLastWebErrorMessage

public static java.lang.String GetLastWebErrorMessage()
Returns the lastest error message received or sent by Change Address or CAP PIN change.