⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shaibuttoncopr.java

📁 这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
   }   /**    * <P>Sets up this coprocessor object based on the contents of the file    * <code>coprFilename</code> stored on <code>owc</code>. This sets    * all the properties of the object as a consequence of what's in    * the coprocessor file.</P>    *    * <P>For the proper format of the coprocessor data file, see the    * document entitled "Implementing Secured D-Identification and E-Payment    * Applications using SHA iButtons".  For the format of TMEX file    * structures, see Application Note 114.    *    * @param owc The DS1963S used as a coprocessor    * @param coprFilename The TMEX filename where coprocessor configuration    *        data is stored.  Usually, "COPR.0".    *    * @throws OneWireIOException on a 1-Wire communication error such as    *         reading an incorrect CRC from a 1-Wire device.  This could be    *         caused by a physical interruption in the 1-Wire Network due to    *         shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.    * @throws OneWireException on a communication or setup error with the 1-Wire    *         adapter    *    * @see #SHAiButtonCopr(OneWireContainer18,String,boolean,int,int,int,int,int,byte,byte[],byte[],byte[],byte[],byte[],byte[],byte[],byte[],byte[])    */   public SHAiButtonCopr(OneWireContainer18 owc, String coprFilename)      throws OneWireException, OneWireIOException   {      setiButton(owc, coprFilename);   }   // ***********************************************************************   // Modifier Methods   //  - setiButton is the only essential modifier.  It updates all   //    data members based on contents of service file alone.   // ***********************************************************************   /**    * <P>Sets up this coprocessor object based on the contents of the file    * <code>coprFilename</code> stored on <code>owc</code>. This sets    * all the properties of the object as a consequence of what's in    * the coprocessor file.</P>    *    * <P>In essence, this is the classes only proper modifier.  All data    * members should be set by this method alone.</P>    *    * <P>For the proper format of the coprocessor data file, see the    * document entitled "Implementing Secured D-Identification and E-Payment    * Applications using SHA iButtons".  For the format of TMEX file    * structures, see Application Note 114.    *    * @param owc The DS1963S used as a coprocessor    * @param coprFilename The TMEX filename where coprocessor configuration    *        data is stored.  Usually, "COPR.0".    *    * @throws OneWireIOException on a 1-Wire communication error such as    *         reading an incorrect CRC from a 1-Wire device.  This could be    *         caused by a physical interruption in the 1-Wire Network due to    *         shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.    * @throws OneWireException on a communication or setup error with the 1-Wire    *         adapter    *    */   private void setiButton(OneWireContainer18 owc, String coprFilename)      throws OneWireException, OneWireIOException   {      //hold container reference      this.ibc = owc;      //and address      this.address = owc.getAddress();      OWFileInputStream fis = null;      try      {         if(DEBUG)            IOHelper.writeLine("opening file: " + coprFilename + " on token: " + owc);         fis = new OWFileInputStream(owc, coprFilename);      }      catch(OWFileNotFoundException e)      {         if(DEBUG)            e.printStackTrace();         throw new OneWireIOException("Coprocessor service file Not found: " + e);      }      try      {         //configures this object from the info in the given stream         fromStream(fis);      }      catch(IOException ioe)      {         if(DEBUG)            ioe.printStackTrace();         throw new OneWireException("Bad Data in Coproccessor Service File: " + ioe);      }      finally      {         try         {               fis.close();         }         catch(IOException ioe)         { /*well, at least I tried!*/; }      }      //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\      if(DEBUG)      {         IOHelper.writeLine("------------------------------------");         IOHelper.writeLine("Loaded Coprocessor");         IOHelper.writeLine("address");         IOHelper.writeBytesHex(owc.getAddress());         IOHelper.writeLine("signPageNumber: " + signPageNumber);         IOHelper.writeLine("authPageNumber: " + authPageNumber);         IOHelper.writeLine("wspcPageNumber: " + wspcPageNumber);         IOHelper.writeLine("serviceFilename");         IOHelper.writeBytesHex(filename);         IOHelper.writeLine("bindData");         IOHelper.writeBytesHex(bindData);         IOHelper.writeLine("bindCode");         IOHelper.writeBytesHex(bindCode);         IOHelper.writeLine("initialSignature");         IOHelper.writeBytesHex(initialSignature);         IOHelper.writeLine("signingChallenge");         IOHelper.writeBytesHex(signingChallenge);         IOHelper.writeLine("------------------------------------");      }      //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\   }   /*   Do I even need modifiers.  The class should only be modified with   "setibutton"   // ***********************************************************************   // Protected Modifiers   //  - All modifiers of this class's data are protected.  The reason   //    is that all data members are set based on information in the   //    Coprocessor's service file.  These member's should never be   //    directly updated by User applications, but rather as a result   //    to changes in the service file.   // ***********************************************************************   protected void setSigningPageNumber(int pg)   {      this.signPageNumber = pg;   }   protected void setWorkspacePageNumber(int pg)   {      this.wspcPageNumber = pg;   }   protected void setAuthenticationPageNumber(int pg)   {      this.authPageNumber = pg;   }   protected void setFilename(byte[] l_filename, int offset)   {      int cnt = Math.min(l_filename.length - offset, 4);      System.arraycopy(l_filename, offset, filename, 0, cnt);   }   protected void setFilenameExt(byte ext)   {      filename[4] = ext;   }   protected void setBindData(byte[] l_bindData, int offset)   {      int cnt = Math.min(l_bindData.length - offset, 32);      System.arraycopy(l_bindData, offset, bindData, 0, cnt);   }   protected void setBindCode(byte[] l_bindCode, int offset)   {      int cnt = Math.min(l_bindCode.length - offset, 7);      System.arraycopy(l_bindCode, offset, bindCode, 0, cnt);   }   protected synchronized void setSigningChallenge (byte[] chlg, int offset)   {      int cnt = (chlg.length > (3+offset)) ? 3 : (chlg.length - offset);      System.arraycopy(chlg, offset, signingChallenge, 0, cnt);   }   protected synchronized void setInitialSignature (byte[] sig_ini, int offset)   {      int cnt = (sig_ini.length > (20+offset)) ? 20 : (sig_ini.length - offset);      System.arraycopy(sig_ini, offset, initialSignature, 0, cnt);   }*/   // ***********************************************************************   // Begin Accessor Methods   // ***********************************************************************   /**    * <P>Returns the 8 byte address of the OneWireContainer this    * SHAiButton refers to.</P>    *    * @return 8 byte array containing family code, address, and    *         crc8 of the OneWire device.    */   public byte[] getAddress()   {      byte[] data = new byte[8];      System.arraycopy(address,0,data,0,8);      return data;   }   /**    * <P>Copies the 8 byte address of the OneWireContainer into    * the provided array starting at the given offset.</P>    *    * @param data array with at least 8 bytes after offset    * @param offset the index at which copying starts    */   public void getAddress(byte[] data, int offset)   {      System.arraycopy(address, 0, data, offset, 8);   }   /**    * <P>Copies the specified number of bytes from the address    * of the OneWireContainer into the provided array starting    * at the given offset.</P>    *    * @param data array with at least cnt bytes after offset    * @param offset the index at which copying starts    * @param cnt the number of bytes to copy    */   public void getAddress(byte[] data, int offset, int cnt)   {      System.arraycopy(address, 0, data, offset, cnt);   }   /**    * <P>Returns the page number used by this coprocessor for storing    * system authentication secret and recreating user's authentication    * secret.  The authentication secret stays constant, while the new    * secret is copied on to the secret corresponding to the workspace    * page.</P>    *    * @return page number used for system authentication secret    * @see OneWireContainer18#bindSecretToiButton(int,byte[],byte[],int)    */   public int getAuthenticationPageNumber()   {      return this.authPageNumber;   }   /**    * <P>Returns a string representing the auxilliary data associated    * with this coprocessor's service.</P>    *    * @return the auxilliary data of this coprocessor's service    */   public String getAuxilliaryData()   {      return auxData;   }   /**    * <P>Returns 7 byte binding code for finalizing secret installation    * on user buttons.  This is copied into the user's scratchpad,    * along with 8 other bytes of binding data (see    * <code>bindSecretToiButton</code>) for finalizing the secret    * and making it unique to the button.</P>    *    * @return the binding code for user's scratchpad    * @see OneWireContainer18#bindSecretToiButton(int,byte[],byte[],int)    */   public byte[] getBindCode()   {      byte[] data = new byte[7];      System.arraycopy(bindCode, 0, data, 0, 7);      return data;   }   /**    * <P>Copies 7 byte binding code for finalizing secret installation    * on user buttons.  This is copied into the user's scratchpad,    * along with 8 other bytes of binding data (see    * <code>bindSecretToiButton</code>) for finalizing the secret    * and making it unique to the button.</P>    *    * @param data array for copying the binding code for user's    *        scratchpad    * @param offset the index at which to start copying.    * @see OneWireContainer18#bindSecretToiButton(int,byte[],byte[],int)    */   public void getBindCode(byte[] data, int offset)   {      System.arraycopy(bindCode, 0, data, offset, 7);   }   /**    * <P>Returns 32 byte binding data for finalizing secret installation    * on user buttons.  This is copied into the user's account data    * page (see <code>bindSecretToiButton</code>) for finalizing the    * secret and making it unique to the button.</P>    *    * @return the binding data for user's data page    * @see OneWireContainer18#bindSecretToiButton(int,byte[],byte[],int)    */   public byte[] getBindData()   {      byte[] data = new byte[32];      System.arraycopy(bindData, 0, data, 0, 32);      return data;   }   /**    * <P>Copies 32 byte binding data for finalizing secret installation    * on user buttons.  This is then copied into the user's account data    * page (see <code>bindSecretToiButton</code>) for finalizing the    * secret and making it unique to the button.</P>    *    * @param data array for copying the binding data for user's    *        data page    * @param offset the index at which to start copying.    * @see OneWireContainer18#bindSecretToiButton(int,byte[],byte[],int)    */   public void getBindData(byte[] data, int offset)   {      System.arraycopy(bindData, 0, data, offset, 32);   }   /**    * <P>Returns an integer representing the encryption code for    * this coprocessor.  No handling of specific encryption codes    * are in place with this API, but could be added easily at    * the <code>SHATransaction</codE> layer.</P>    *    * @return an integer representing type of encryption for user data.    */   public int getEncryptionCode()   {      return encCode;   }   /**    * <P>Copies the filename (used for storing account data on user    * buttons) into the specified array starting at the specified    * offset.</P>    *    * @param l_filename the array into which the filename will be    *        copied.    * @param offset the starting index for copying the filename.    */   public void getFilename(byte[] l_filename, int offset)   {      int cnt = Math.min(l_filename.length - offset, 4);      System.arraycopy(filename, offset, l_filename, offset, cnt);   }   /**    * <P>Returns the extension of the filename used for storing account    * data on user buttons.  If the type of this service is an    * e-cash application, the file extension will be decimal 102.</P>    *    * @return proper file extension for user's account data file.    */   public byte getFilenameExt()   {      return filename[4];   }   /**    * <P>Returns the 20-byte initial signature used by this coprocessor    * for signing account data.</P>    *    * @return 20-byte initial signature.    */   public byte[] getInitialSignature()   {      byte[] data = new byte[20];      System.arraycopy(initialSignature, 0, data, 0, 20);      return data;   }   /**    * <P>Copies the 20-byte initial signature used by this coprocessor    * for signing account data into the specified array starting at the    * specified offset.</P>    *    * @param data arry for copying the 20-byte initial signature.    * @param offset the index at which to start copying.    */   public void getInitialSignature(byte[] data, int offset)   {      System.arraycopy(initialSignature, 0, data, offset, 20);   }   /**

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -