Ejemplo n.º 1
0
 /**
  * Let the passport sign a message using the passports own private key.
  *
  * @param message The message to sign (can be any size)
  * @return A signature, the response from the passport.
  * @throws CardServiceException Gets thrown when there's a problem communicating with the
  *     passport.
  * @throws NoSuchAlgorithmException Gets thrown when there's no SHA1 provider present.
  */
 public byte[] signWithAA(byte[] message) throws CardServiceException, NoSuchAlgorithmException {
   if (activateTerminal()) {
     DG15File dg15 = new DG15File(_activePassportService.readFile(PassportService.EF_DG15));
     PublicKey publicKey = dg15.getPublicKey();
     MessageDigest digest = MessageDigest.getInstance("SHA1");
     byte[] digestedMessage = digest.digest(message);
     byte[] m2 = new byte[8];
     System.arraycopy(digestedMessage, 0, m2, 0, m2.length);
     return _activePassportService.sendAA(publicKey, m2);
   }
   return new byte[0];
 }