/** * Get the active cipher suites. * * <p>In TLS 1.1, many weak or vulnerable cipher suites were obsoleted, such as * TLS_RSA_EXPORT_WITH_RC4_40_MD5. The implementation MUST NOT negotiate these cipher suites in * TLS 1.1 or later mode. * * <p>Therefore, when the active protocols only include TLS 1.1 or later, the client cannot * request to negotiate those obsoleted cipher suites. That is, the obsoleted suites should not be * included in the client hello. So we need to create a subset of the enabled cipher suites, the * active cipher suites, which does not contain obsoleted cipher suites of the minimum active * protocol. * * <p>Return empty list instead of null if no active cipher suites. */ CipherSuiteList getActiveCipherSuites() { if (activeCipherSuites == null) { if (activeProtocols == null) { activeProtocols = getActiveProtocols(); } ArrayList<CipherSuite> suites = new ArrayList<>(); if (!(activeProtocols.collection().isEmpty()) && activeProtocols.min.v != ProtocolVersion.NONE.v) { for (CipherSuite suite : enabledCipherSuites.collection()) { if (suite.obsoleted > activeProtocols.min.v && suite.supported <= activeProtocols.max.v) { if (algorithmConstraints.permits( EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), suite.name, null)) { suites.add(suite); } } else if (debug != null && Debug.isOn("verbose")) { if (suite.obsoleted <= activeProtocols.min.v) { System.out.println("Ignoring obsoleted cipher suite: " + suite); } else { System.out.println("Ignoring unsupported cipher suite: " + suite); } } } } activeCipherSuites = new CipherSuiteList(suites); } return activeCipherSuites; }
/* * Get the active protocol versions. * * In TLS 1.1, many weak or vulnerable cipher suites were obsoleted, * such as TLS_RSA_EXPORT_WITH_RC4_40_MD5. The implementation MUST NOT * negotiate these cipher suites in TLS 1.1 or later mode. * * For example, if "TLS_RSA_EXPORT_WITH_RC4_40_MD5" is the * only enabled cipher suite, the client cannot request TLS 1.1 or * later, even though TLS 1.1 or later is enabled. We need to create a * subset of the enabled protocols, called the active protocols, which * contains protocols appropriate to the list of enabled Ciphersuites. * * Return empty list instead of null if no active protocol versions. */ ProtocolList getActiveProtocols() { if (activeProtocols == null) { ArrayList<ProtocolVersion> protocols = new ArrayList<>(4); for (ProtocolVersion protocol : enabledProtocols.collection()) { boolean found = false; for (CipherSuite suite : enabledCipherSuites.collection()) { if (suite.isAvailable() && suite.obsoleted > protocol.v && suite.supported <= protocol.v) { if (algorithmConstraints.permits( EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), suite.name, null)) { protocols.add(protocol); found = true; break; } else if (debug != null && Debug.isOn("verbose")) { System.out.println("Ignoring disabled cipher suite: " + suite + " for " + protocol); } } else if (debug != null && Debug.isOn("verbose")) { System.out.println("Ignoring unsupported cipher suite: " + suite + " for " + protocol); } } if (!found && (debug != null) && Debug.isOn("handshake")) { System.out.println("No available cipher suite for " + protocol); } } activeProtocols = new ProtocolList(protocols); } return activeProtocols; }
/** * Select a protocol version from the list. Called from ServerHandshaker to negotiate protocol * version. * * <p>Return the lower of the protocol version suggested in the clien hello and the highest * supported by the server. */ ProtocolVersion selectProtocolVersion(ProtocolVersion protocolVersion) { if (activeProtocols == null) { activeProtocols = getActiveProtocols(); } return activeProtocols.selectProtocolVersion(protocolVersion); }
/** Check if the given protocol version is enabled and available. */ boolean isNegotiable(ProtocolVersion protocolVersion) { if (activeProtocols == null) { activeProtocols = getActiveProtocols(); } return activeProtocols.contains(protocolVersion); }
/** * Prior to handshaking, activate the handshake and initialize the version, input stream and * output stream. */ void activate(ProtocolVersion helloVersion) throws IOException { if (activeProtocols == null) { activeProtocols = getActiveProtocols(); } if (activeProtocols.collection().isEmpty() || activeProtocols.max.v == ProtocolVersion.NONE.v) { throw new SSLHandshakeException("No appropriate protocol"); } if (activeCipherSuites == null) { activeCipherSuites = getActiveCipherSuites(); } if (activeCipherSuites.collection().isEmpty()) { throw new SSLHandshakeException("No appropriate cipher suite"); } // temporary protocol version until the actual protocol version // is negotiated in the Hello exchange. This affects the record // version we sent with the ClientHello. if (!isInitialHandshake) { protocolVersion = activeProtocolVersion; } else { protocolVersion = activeProtocols.max; } if (helloVersion == null || helloVersion.v == ProtocolVersion.NONE.v) { helloVersion = activeProtocols.helloVersion; } // We accumulate digests of the handshake messages so that // we can read/write CertificateVerify and Finished messages, // getting assurance against some particular active attacks. Set<String> localSupportedHashAlgorithms = SignatureAndHashAlgorithm.getHashAlgorithmNames(getLocalSupportedSignAlgs()); handshakeHash = new HandshakeHash(!isClient, needCertVerify, localSupportedHashAlgorithms); // Generate handshake input/output stream. input = new HandshakeInStream(handshakeHash); if (conn != null) { output = new HandshakeOutStream(protocolVersion, helloVersion, handshakeHash, conn); conn.getAppInputStream().r.setHandshakeHash(handshakeHash); conn.getAppInputStream().r.setHelloVersion(helloVersion); conn.getAppOutputStream().r.setHelloVersion(helloVersion); } else { output = new HandshakeOutStream(protocolVersion, helloVersion, handshakeHash, engine); engine.inputRecord.setHandshakeHash(handshakeHash); engine.inputRecord.setHelloVersion(helloVersion); engine.outputRecord.setHelloVersion(helloVersion); } // move state to activated state = -1; }
/** * Handler�� implements �� �ҵ�. �ٸ� Ŭ�����κ��� ���� Message�� �´�. * * @param MessageType int ���� ���� * @param data Object ������ ���� ���� ������ */ @Override public void OnHandleMessage(int MessageType, Object data) { switch (MessageType) { // Protocol �� �о��ٴ� ���� �� ��� case MESSAGE_READ_PROTOCOL: // Protocol ����Ʈ�� ����ִ�. Action[] actions = (Action[]) data; // null �� ���� �������� ������ �߸� �ҷ��� ��� if (actions == null) JOptionPane.showMessageDialog(this, "�ùٸ��� ���� Protocol �����Դϴ�."); else { // �÷��� �ʱ�ȭ IsProtocolRead = false; // action�� 0��° �迭�� ���̺��� null�� ���� �߸��� ������ ���. if (actions[0].getLabel() == null) return; // List�� ����ش�. m_ProtocolList.ResetContent(); // ���� �������� ��ŭ insert ���ش�. for (Action action : actions) { m_ProtocolList.InsertData(action); } int total = 0; int goton = 0; for (int i = 0; i < actions.length; i++) { if (!actions[i].getLabel().equals("GOTO")) total += Integer.parseInt(actions[i].getTime()); else { int count = Integer.parseInt(actions[i].getTime()); if (goton < count) { String gotoLabel = actions[i].getTemp(); for (int j = 0; j < actions.length; j++) { if (actions[j].getLabel().equals(gotoLabel)) { i = j - 1; break; } } goton++; } else { goton = 0; } } } // �ƿ� �������ݵ��� ��������� �������ش�. m_ActionList = actions; // �о�� �������� ������ �̸��� ��ܿ� ǥ���Ѵ�. m_ProtocolText.setProtocolText(actions[0].getProtocolName()); m_ProtocolText.setRemainingTimeText( String.format( "%02d:%02d:%02d", total / 3600, (total % 3600) / 60, (total % 3600) % 60)); // �о����� �÷��� true IsProtocolRead = true; } break; // ��ŸƮ ��ư�� ������ ��. case MESSAGE_START_PCR: if (IsConnected) { // �ҷ��� �������� ������ ���� ��쿡�� ���� if (IsProtocolRead) { rLEDOff(); m_PCRTask.PCR_Start(m_LidText.getText()); m_PCRTask.setTimer(GoTimer.TIMER_NUMBER); m_ButtonUI.setEnable(ButtonUI.BUTTON_START, false); m_ButtonUI.setEnable(ButtonUI.BUTTON_STOP, true); m_ButtonUI.setEnable(ButtonUI.BUTTON_PROTOCOL, false); } else { JOptionPane.showMessageDialog(this, "�ҷ��� �������� ������ �����ϴ�."); } } break; // ��ž ��ư�� ������ �� case MESSAGE_STOP_PCR: if (IsConnected) { // ���� ó�� m_PCRTask.Stop_PCR(); m_ButtonUI.setEnable(ButtonUI.BUTTON_START, true); m_ButtonUI.setEnable(ButtonUI.BUTTON_STOP, false); m_ButtonUI.setEnable(ButtonUI.BUTTON_PROTOCOL, true); // �÷��� ���� IsNoStop = false; // Stop ������ �˸��� ���α��� �� final ProgressDialog dialog = new ProgressDialog(this, "Stoping this device...", 10); // ����� ����� ���� ��� ��ȭ���ڸ� ���� ���� ������ ���� Thread tempThread = new Thread() { public void run() { dialog.setModal(true); dialog.setVisible(true); } }; tempThread.start(); // 0.2�� ���� ���α����ٰ� 1ĭ�� �����ϵ��� 2���� ���� �ð��� �д�. ( �������� ���Ḧ ���� ) Thread tempThread2 = new Thread() { public void run() { for (int i = 1; i <= 10; i++) { dialog.setProgressValue(i); try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } } dialog.setVisible(false); m_PCRTask.PCR_End(); } }; tempThread2.start(); } break; // Start ����, �������ݵ��� ���� ���� ���� ��쿡 NOP Ÿ�̸Ӹ� ���� ��Ű�� ���� ���� case MESSAGE_TASK_WRITE_END: try { Thread.sleep(300); } catch (InterruptedException e) { e.printStackTrace(); } // NopTimer ���۽�Ų��. m_PCRTask.setTimer(NopTimer.TIMER_NUMBER); break; } }
/** * UI�� �ʱ�ȭ �ϰų�, ��ü���� �ʱ�ȭ �ϴ� ������ �Ѵ�. MainUI() �����ڿ����� ȣ���� �� �ִ�. �� �ѹ��� ȣ��ȴ�. */ private void init() { // �������� ũ�� ���� setBounds( (Resolution.X * 2 / 5), Resolution.Y / 4, UIConstant.MYPCR_WIDTH, UIConstant.MYPCR_HEIGHT); // Ÿ��Ʋ ���� setTitle("MyPCR version 3.2"); // ����� ���α� ���� setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // �ִ�ȭ ���� setResizable(false); // title icon ���� setIconImage(new ImageIcon(getClass().getClassLoader().getResource("icon.png")).getImage()); // ���� ������Ʈ�� ������� Panel // ���̾ƿ��� ������ǥ�� ����ϱ� ���� null�� ���� m_Panel = new JPanel(); m_Panel.setLayout(null); m_Panel.setBackground(UIConstant.BACKGROUND_COLOR); // 3���� GroupBox�� title String[] titles = {"Serial Number", "CHAMBER", "LID HEATER"}; /** ������Ʈ ���� * */ m_ProtocolText = new ProtocolText(); m_PCRStatusText = StatusText.getInstance(UIConstant.GROUP_SIZE, titles); m_ProtocolList = ProtocolList.getInstance(); m_ButtonUI = ButtonUI.getInstance(this); m_LidText = new JTextField(); m_LidText.setLayout(null); m_LidText.setBounds(310, 55, 40, 20); m_LidText.setText("104"); m_LidText.addKeyListener(this); // �ΰ� �߰� JLabel labelLogo = new JLabel(new ImageIcon(getClass().getClassLoader().getResource("logo.jpg"))); labelLogo.setBounds(100, 385, 182, 37); // for bootloader mode labelLogo.addMouseListener( new MouseListener() { public void mouseReleased(MouseEvent e) {} public void mousePressed(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 3 && currentVersion != null) { String res = JOptionPane.showInputDialog( null, "Please input admin password for bootloader", "Admin Mode(Firmware V" + currentVersion + ")", JOptionPane.OK_CANCEL_OPTION); if (res != null) { if (res.equals(Constants.ADMIN_PASSWORD)) { if (m_ButtonUI.isEnable(ButtonUI.BUTTON_START)) OnHandleMessage(MESSAGE_STOP_PCR, null); Thread tempThread = new Thread() { public void run() { try { Thread.sleep(1000); OnMessage(DISCONNECTED, null, 0); Thread.sleep(1000); m_Device.write(m_PCRTask.m_TxAction.Tx_BootLoader()); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }; tempThread.start(); } else JOptionPane.showMessageDialog( null, "Wrong password!", "Admin Mode", JOptionPane.WARNING_MESSAGE); } } } }); // LED added icon_blueOff = new ImageIcon(url_blueOff); icon_blueOn = new ImageIcon(url_blueOn); icon_greenOff = new ImageIcon(url_greenOff); icon_greenOn = new ImageIcon(url_greenOn); icon_redOff = new ImageIcon(url_redOff); icon_redOn = new ImageIcon(url_redOn); ledBlue = new JLabel(icon_blueOff); ledBlue.setBounds(310, 1, 22, 29); ledRed = new JLabel(icon_redOff); ledRed.setBounds(332, 1, 22, 29); ledGreen = new JLabel(icon_greenOff); ledGreen.setBounds(354, 1, 22, 29); m_Panel.add(m_ProtocolText); m_Panel.add(m_PCRStatusText); m_Panel.add(m_ProtocolList.getPane()); m_Panel.add(m_ButtonUI.getPanel()); m_Panel.add(m_LidText); // 150509 logo and led added m_Panel.add(labelLogo); m_Panel.add(ledBlue); m_Panel.add(ledGreen); m_Panel.add(ledRed); /** ������Ʈ ���� * */ // �dz��� ���� �����ӿ� ���� add(m_Panel); // 150507 ȭ�鿡 UI �� ���� ���� ��ġ Ȯ���� ���� �ϱ� ���� ó�� // ȭ�鿡 ���̵��� // setVisible(true); // Device ���� üũ�� �ݹ� �Լ� ���� try { // DeviceManager �ν��Ͻ� ���� m_Manager = HIDManager.getInstance(); // Device ���� ���¸� ǥ�����ִ� �ݹ��Լ� ��� m_Callback_DeviceChange = CallbackDeviceChange.getInstance(m_Manager, this); m_Callback_DeviceChange.setDaemon(true); m_Callback_DeviceChange.start(); } catch (IOException e) { e.printStackTrace(); } // MyPCR ���� ����� ��� �ִ� ��ü�� �ν��Ͻ��� ���� m_PCRTask = PCR_Task.getInstance(this); }