Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38388

Re: Why is Java 7 converting the Password toCharArray instead of Byte in it's PBKDF2 function?

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Robert Klemme <shortcutter@googlemail.com>
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 Mon, 18 Jun 2018 18:41:55 +0200
Lines 31
Message-ID <foq5mlF5sm0U1@mid.individual.net> (permalink)
References <pdf0kv$uom$1@news.albasani.net> <pdfjv8$e8s$1@news.albasani.net>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net E4aebdeQeyk8rfKJntg97wkBi6B1eiKX53EBDqbWAE1xCV2rA=
Cancel-Lock sha1:DjMSuoJ/IuI+oorvWovavk+Ib9s=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0
In-Reply-To <pdfjv8$e8s$1@news.albasani.net>
Content-Language en-US
Xref csiph.com sci.crypt:43711 comp.lang.java.programmer:38388

Cross-posted to 2 groups.

Show key headers only | View raw


On 15.05.2018 23:37, Karl.Frank wrote:
> Holy moley! It's a buggy Java Library I'm currently using!!

You are converting a byte array to a String without explicit mention of 
the encoding.  Maybe the way Java picks up the default encoding has 
changed between versions.  Anyway, this is an unsafe practice.

Also, you are reading only once, there is the chance that there is still 
data in the pipe which you will miss.  Even worse, depending on how data 
is written to stdin you might even get different results.  This might 
not be an issue for your test program, but could be if you use this code 
in production.

Btw. I find your habit of using names beginning with an uppercase letter 
for variables confusing.  Conventionally these are reserved for classes 
and interfaces.

> So my own implementation works correctly - what a relieve!

There are cases where wrong code emits correct results - and this 
surfaces only later, when the input or some other environmental factor 
changes.

Regards

	robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Why is Java 7 converting the Password toCharArray instead of Byte in it's PBKDF2 function? "Karl.Frank" <Karl.Frank@Freecx.co.uk> - 2018-05-15 23:37 +0200
  Re: Why is Java 7 converting the Password toCharArray instead of Byte in it's PBKDF2 function? "Karl.Frank" <Karl.Frank@Freecx.co.uk> - 2018-05-16 15:58 +0200
  Re: Why is Java 7 converting the Password toCharArray instead of Byte in it's PBKDF2 function? Robert Klemme <shortcutter@googlemail.com> - 2018-06-18 18:41 +0200
    Re: Why is Java 7 converting the Password toCharArray instead of Byte in it's PBKDF2 function? "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-06-18 13:33 -0700
    Re: Why is Java 7 converting the Password toCharArray instead of Byte in it's PBKDF2 function? "Karl.Frank" <Karl.Frank@Freecx.co.uk> - 2018-06-19 12:54 +0200
      Re: Why is Java 7 converting the Password toCharArray instead of Byte in it's PBKDF2 function? Lothar Kimmeringer <news201705@kimmeringer.de> - 2018-06-19 22:18 +0200
        Re: Why is Java 7 converting the Password toCharArray instead of Byte in it's PBKDF2 function? Robert Klemme <shortcutter@googlemail.com> - 2018-06-19 23:20 +0200
        Re: Why is Java 7 converting the Password toCharArray instead of Byte in it's PBKDF2 function? "Karl.Frank" <Karl.Frank@Freecx.co.uk> - 2018-06-19 23:23 +0200
      Re: Why is Java 7 converting the Password toCharArray instead of Byte in it's PBKDF2 function? Robert Klemme <shortcutter@googlemail.com> - 2018-06-19 23:15 +0200
        Re: Why is Java 7 converting the Password toCharArray instead of Byte in it's PBKDF2 function? "Karl.Frank" <Karl.Frank@Freecx.co.uk> - 2018-06-20 00:03 +0200

csiph-web