Initial TLSv1.3 implementation Released to the Open Sandbox.

2018-05-11 Thread Bradford Wetmore


Development of the TLSv1.3 protocol has been underway within the IETF 
TLS Working Group for several years.  After 28 revisions, the resulting 
Internet-Draft [1] has finally reached the RFC Editor's Desk, and is 
close to release as an RFC.


We've also been actively working on a TLSv1.3 implementation for the 
JDK.  We've placed our work so far into the OpenJDK "open sandbox" [2] 
so that you see what's happening.  (See the Mercurial branch 
"JDK-8145252-TLS13-branch".)


If you're not familiar with OpenJDK sandbox/branches, please see Chris 
Hegarty's "JDK Sandbox Development Repository" [3].  His page provides 
details of the OpenJDK sandbox/branches, but here's a quick primer if 
you just want to get to the source quickly:


% hg clone http://hg.openjdk.java.net/jdk/sandbox/ sandbox
% cd sandbox
% hg update -r JDK-8145252-TLS13-branch

The current branch includes the TLSv1.3 implementation, plus a snapshot 
of the RSASSA-PSS code [4] from PKCS#1 v2.2, which is being done under 
JDK-8190180 [5].


I've also placed a webrev on CR [6].

Please note well: this branch is under very active development and is 
not final by any means.  Also note: by releasing this code, we are not 
committing a specific release or timeframe.  We will continue 
development and fixing bugs until the code is ready for inclusion in the 
JDK.


Have a look around, and of course, we welcome your feedback.

Thanks,
Brad

[1] https://datatracker.ietf.org/doc/draft-ietf-tls-tls13/
[2] http://hg.openjdk.java.net/jdk/sandbox/
[3] http://cr.openjdk.java.net/~chegar/docs/sandbox.html
[4] http://mail.openjdk.java.net/pipermail/security-dev/2018-May/017137.html
[5] https://bugs.openjdk.java.net/browse/JDK-8190180
[6] http://cr.openjdk.java.net/~wetmore/8145252/



Re: RFR CSR 8202590: Customizing the generation of a PKCS12 keystore

2018-05-11 Thread Michael StJohns

On 5/9/2018 6:06 AM, Weijun Wang wrote:

Hi Mike

Your comments make sense. However,

1. I don't think it's easy in JDK to break a PBE algorithm into PBKDF + Cipher. For example, I cannot create 
a SecretKey from SecretKeyFactory.getInstance("PBEWithSHA1AndDESede") and use it to init a 
Cipher.getInstance("DESede"). I still have to use 
Cipher.getInstance("PBEWithSHA1AndDESede").


No - you'd instantiate a KDF using PBE, derive the secret key from the 
password, and use it with DESede.   Right now, you're hiding a KDF under 
the cover of turning a secret key spec into a secret key.


And right now, all of this is actually hidden under the KeyStore 
covers.    If you're going to use compound algorithm names, what I'd 
rather do is


   KeyStore ks = KeyStore.getInstance("PKCS12/PBKDF2/HMAC-SHA256/AES-KW");

Or  ///

And have the generic KeyStore.getInstance("PKCS12")  return what you 
specify in the preferences, or a general parser for things you're 
reading in.





2. If I read correctly, MacData in pkcs12 (https://tools.ietf.org/html/rfc7292#page-11) 
always uses the old style KDF (https://tools.ietf.org/html/rfc7292#appendix-B). If we 
have a "pbkdf" setting, it might mislead a user to believe it's also used by 
MacData generation.


You are - unfortunately - correct that Appendix B is still used for the 
KDF for macdata keys.  That appears to be a bug as you shouldn't be 
using the same key (password) for different algorithms and also appears 
to be a backwards compatibility item from the previous versions of 
PKCS12.  I'll ask the CFRG  what they think about it.


But I disagree with the "mislead a user".  As you note, Appendix B is 
specific that it's the only source for macdata KDFs, and you could 
include a note in the spec that this only applies to deriving data 
encryption keys rather than the macdata key.




I looked at openssl and it also has independent -certpbe and -keypbe.

Also, setting multiple algorithms with a preference order might not be what we 
wish for. The choice of algorithms is first about security and second about 
interoperability. By assigning *only* one algorithm for each usage, we are 
clear what the default algorithms are. For example, Oracle's JDK release will 
set them to match our crypto roadmap. Or, an application vendor or system 
administrator can choose their algorithms if it can be guaranteed that all 
parties using the application or inside a certain enterprise support the 
algorithms.


You've got a fair point - but I'd disagree that assigning default 
algorithms is about security, it really is about interoperability - 
making sure that the most number of people can handle the PKCS12 object 
without installing additional providers.   But seriously,


|keystore.pkcs12.certProtectionAlgorithm = PBEWithSHA1AndRC2_40|

is not a security choice!

But, after thinking about it a bit more, the preference list isn't 
useful without additional providers - and at that point you're probably 
generating stuff by specifying algorithms and such so I agree with no 
preference list.  Could you please, please, please not use weak 
algorithms as the default here though?




Thanks
Max


On May 5, 2018, at 10:50 PM, Michael StJohns  wrote:

On 5/5/2018 3:38 AM, Weijun Wang wrote:

Please take a review of


https://bugs.openjdk.java.net/browse/JDK-8202590



This enhancement has two major purposes:

1. Provide a way to change encryption and Mac algorithms used in PKCS 12.

2. The ability to create a password-less PKCS 12 keystore containing 
unencrypted certificates and no Mac.

Especially, the long paragraph in the spec on behavior of an existing keystore 
makes sure that once a password-less keystore is generated (with 
-Dkeystore.pkcs12.certProtectionAlgorithm=NONE and 
-Dkeystore.pkcs12.macAlgorithm=NONE), one can add new certificates to it 
without any special setting and keep it password-less.

Thanks
Max



I think you want to break this into two parts - the first part specifies the 
algorithm used to convert a password into key material. The second defines the 
algorithms used for protection for the various parts.
# password to key material scheme
.pbkdf=PBKDF2withHMAC-SHA256  (Form is base function with the PRF)
# PKCS12 macData
.macAlgorithm=HMAC-SHA256  # this is the algorithm for the PKCS12 macData 
component, if NONE, this component is not present
# protection scheme for PKCS8ShroudedKeyBagn if NONE, then a PKCS8KeyBag is 
produced instead.
.keyProtectionAlgorithm=AES-KWA
#protection scheme for certificates - produces an encryptedData object encrypted under 
the scheme, or a certBag object if "NONE" is specified
.certProtectionAlgorithm=NONE


Second, you probably want to do this as multi-choice entries in the 
java.security file ala providers:

.pbkdf.0=PBKDF2withSHA256
.pbkdf.9=PBKDF1withSHA1 # the current default aka pbe

So that you can specify a somewhat secure default, but still allow for 
providers that don't implement the stronger