示例#1
0
 /**
  * To save from Attacks on Parameter Authentication one can send hash of parameters to other party
  *
  * @return byte[] of what???
  */
 @Override
 public byte[] getParametersHash() {
   byte[] parms = NativeLib.getECParameters(ecGroup);
   SHA1 sha1 = new SHA1(BLOCK_SIZE);
   sha1.update(parms, 0, parms.length);
   sha1.generate();
   byte[] digest = sha1.getDigest();
   return digest;
 }
示例#2
0
 @Override
 public boolean checkParametersHash(byte[] hash) {
   if (hash == null || hash.length != BLOCK_SIZE) return false;
   byte[] parms = NativeLib.getECParameters(ecGroup);
   SHA1 sha1 = new SHA1(BLOCK_SIZE);
   sha1.update(parms, 0, parms.length);
   sha1.generate();
   byte[] digest = sha1.getDigest();
   for (int i = 0; i < digest.length; i++) if (digest[i] != hash[i]) return false;
   return true;
 }
示例#3
0
  /**
   * Runs an integrity test.
   *
   * @return true: selftest passed / false: selftest failed
   */
  public boolean selfTest() {
    int nI;
    SHA1 tester;
    byte[] digest;

    tester = new SHA1();

    tester.update(SELFTEST_MESSAGE);
    tester.finalize();

    digest = tester.getDigest();

    for (nI = 0; nI < DIGEST_SIZE; nI++) {
      if (digest[nI] != SELFTEST_DIGEST[nI]) {
        return false;
      }
    }
    return true;
  }