Path: csiph.com!xmission!feeder.erje.net!1.eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail From: "Karl.Frank" Newsgroups: sci.crypt,comp.lang.java.programmer Subject: Re: Why is Java 7 converting the Password toCharArray instead of Byte in it's PBKDF2 function? Date: Tue, 19 Jun 2018 23:23:09 +0200 Organization: albasani.net Lines: 76 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net pOMi8hiKfjXyZzPN9mn/VqShRL411LZc25k+A6zB9yF9SfZQ4PSkpw5WAtvTcG4LVt1PvHNH69v7jiWUz1cjbAga41TTx8Zz/9NdHktlzEXw/hmnnSuWuczBn9zXyTjj NNTP-Posting-Date: Tue, 19 Jun 2018 21:23:10 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="hmjriEZ3H1KC06J/0doOlFWTz8TLWclY6yK6p6Ye9o9Je8GC41ISzFrWYR9MyjBvZwV7FpmvRr4yue7g8iw2HDHVUeUANpEHIV6j23G4U0m9TpfIJIsbexiXTV3Xyjuv"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0 In-Reply-To: Cancel-Lock: sha1:DZVxEcsid7/qFFHXsDM/cfmRsuI= Xref: csiph.com sci.crypt:43720 comp.lang.java.programmer:38395 On 19.06.18 22:18, Lothar Kimmeringer wrote: > Karl.Frank wrote: > >> The amount of byte to read is exactly defined by >> >> int BuffSize = System.in.available(); >> byte[] pwByte = new byte[BuffSize]; >> System.in.read(pwByte, 0, BuffSize); >> >> How would the program read more byte than necessary? > > InputStream.available only returns the number of bytes that > can be read without blocking. Dependent on how the data ends > up there there still might be data left to read that you > missed because of that. > > What you're doing here is a common programming error. > > > Cheers, Lothar Well, well, well. The posted listing is just a short test program in order to figure out why the results of the Java function were wrong. It clearly does not expext a huge file being passed over by stdin. Obviously in a program that need to handle large scale data one would read in the data byte in chunks and process them subsequently like in this short snipped ---------------------------------------8<---------- int BuffSize = 8192; byte[] inByte = new byte[BuffSize]; byte[] outByte = new byte[BuffSize]; int inB, outB, bufferRead; System.in.flush(); System.out.flush(); while ((bufferRead = System.in.read(inByte, 0, BuffSize)) != -1) { for (int i=0; i8---------- So nothing to be worried about in regards of any unprocessed data left ;-) Cheers, Karl -- cHNiMUBACG0HAAAAAAAAAAAAAABIZVbDdKVM0w1kM9vxQHw+bkLxsY/Z0czY0uv8/Ks6WULxJVua zjvpoYvtEwDVhP7RGTCBVlzZ+VBWPHg5rqmKWvtzsuVmMSDxAIS6Db6YhtzT+RStzoG9ForBcG8k G97Q3Jml/aBun8Kyf+XOBHpl5gNW4YqhiM0=