public static PrivateKey load(InputStream is) throws IOException, CryptoException {
  byte[] pvk=ReadUtil.readFully(is);
  ByteBuffer bb=ByteBuffer.wrap(pvk);
  bb.order(ByteOrder.LITTLE_ENDIAN);
  long keyType=readReservedMagicKeyType(bb);
  long encrypted=UnsignedUtil.getInt(bb);
  if (encrypted != PVK_UNENCRYPTED) {
    throw new PrivateKeyEncryptedException(MessageFormat.format(res.getString("MsPvkIsEncrypted.exception.message"),Long.toHexString(encrypted),Long.toHexString(PVK_UNENCRYPTED)));
  }
  long saltLength=UnsignedUtil.getInt(bb);
  if (saltLength != UNENCRYPTED_SALT_LENGTH) {
    throw new CryptoException(MessageFormat.format(res.getString("InvalidMsPvkSaltLengthField.exception.message"),Long.toHexString(saltLength),Long.toHexString(UNENCRYPTED_SALT_LENGTH)));
  }
  long keyLength=UnsignedUtil.getInt(bb);
  readPrivateKeyBlobHeader(bb,keyType);
  byte[] privateKeyBlob=new byte[bb.remaining()];
  bb.get(privateKeyBlob);
  if (keyLength != (privateKeyBlob.length + BLOB_HEADER_LENGTH)) {
    throw new CryptoException(MessageFormat.format(res.getString("InvalidMsPvkKeyLengthField.exception.message"),Long.toHexString(keyLength),Long.toHexString(privateKeyBlob.length + BLOB_HEADER_LENGTH)));
  }
  return blobToPrivateKey(privateKeyBlob);
}

public static PrivateKey load ( InputStream is ) throws IOException , CryptoException { byte [ ] pvk = ReadUtil . readFully ( is ) ; ByteBuffer bb = ByteBuffer . wrap ( pvk ) ; bb . order ( ByteOrder . LITTLE_ENDIAN ) ; long keyType = readReservedMagicKeyType ( bb ) ; long encrypted = UnsignedUtil . getInt ( bb ) ; if ( encrypted != PVK_UNENCRYPTED ) { throw new PrivateKeyEncryptedException ( MessageFormat . format ( res . getString ( "MsPvkIsEncrypted.exception.message" ) , Long . toHexString ( encrypted ) , Long . toHexString ( PVK_UNENCRYPTED ) ) ) ; } long saltLength = UnsignedUtil . getInt ( bb ) ; if ( saltLength != UNENCRYPTED_SALT_LENGTH ) { throw new CryptoException ( MessageFormat . format ( res . getString ( "InvalidMsPvkSaltLengthField.exception.message" ) , Long . toHexString ( saltLength ) , Long . toHexString ( UNENCRYPTED_SALT_LENGTH ) ) ) ; } long keyLength = UnsignedUtil . getInt ( bb ) ; readPrivateKeyBlobHeader ( bb , keyType ) ; byte [ ] privateKeyBlob = new byte [ bb . remaining ( ) ] ; bb . get ( privateKeyBlob ) ; if ( keyLength != ( privateKeyBlob . length + BLOB_HEADER_LENGTH ) ) { throw new CryptoException ( MessageFormat . format ( res . getString ( "InvalidMsPvkKeyLengthField.exception.message" ) , Long . toHexString ( keyLength ) , Long . toHexString ( privateKeyBlob . length + BLOB_HEADER_LENGTH ) ) ) ; } return blobToPrivateKey ( privateKeyBlob ) ; }
load an unencrypted pvk private key from the stream .
