Esempio n. 1
0
  /**
   * This call, used by the constructors, instantiates the SHA digest and sets the seed, if given.
   */
  private void init(byte[] seed) {
    try {
      digest = MessageDigest.getInstance("SHA");
    } catch (NoSuchAlgorithmException e) {
      throw new InternalError("internal error: SHA-1 not available.", e);
    }

    if (seed != null) {
      engineSetSeed(seed);
    }
  }
Esempio n. 2
0
  /*
   * readObject is called to restore the state of the random object from
   * a stream.  We have to create a new instance of MessageDigest, because
   * it is not included in the stream (it is marked "transient").
   *
   * Note that the engineNextBytes() method invoked on the restored random
   * object will yield the exact same (random) bytes as the original.
   * If you do not want this behaviour, you should re-seed the restored
   * random object, using engineSetSeed().
   */
  private void readObject(j86.java.io.ObjectInputStream s)
      throws IOException, ClassNotFoundException {

    s.defaultReadObject();

    try {
      digest = MessageDigest.getInstance("SHA");
    } catch (NoSuchAlgorithmException e) {
      throw new InternalError("internal error: SHA-1 not available.", e);
    }
  }
Esempio n. 3
0
 static byte[] doTLS12PRF(
     byte[] secret,
     byte[] labelBytes,
     byte[] seed,
     int outputLength,
     String prfHash,
     int prfHashLength,
     int prfBlockSize)
     throws NoSuchAlgorithmException, DigestException {
   if (prfHash == null) {
     throw new NoSuchAlgorithmException("Unspecified PRF algorithm");
   }
   MessageDigest prfMD = MessageDigest.getInstance(prfHash);
   return doTLS12PRF(secret, labelBytes, seed, outputLength, prfMD, prfHashLength, prfBlockSize);
 }
Esempio n. 4
0
 static byte[] doTLS10PRF(byte[] secret, byte[] labelBytes, byte[] seed, int outputLength)
     throws NoSuchAlgorithmException, DigestException {
   MessageDigest md5 = MessageDigest.getInstance("MD5");
   MessageDigest sha = MessageDigest.getInstance("SHA1");
   return doTLS10PRF(secret, labelBytes, seed, outputLength, md5, sha);
 }