diff --git a/jdk/src/share/classes/sun/security/krb5/internal/crypto/EType.java b/jdk/src/share/classes/sun/security/krb5/internal/crypto/EType.java index ee59d215075..abccce82415 100644 --- a/jdk/src/share/classes/sun/security/krb5/internal/crypto/EType.java +++ b/jdk/src/share/classes/sun/security/krb5/internal/crypto/EType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -221,8 +221,8 @@ public static int[] getBuiltInDefaults() { result = BUILTIN_ETYPES; } if (!allowWeakCrypto) { - // The last 2 etypes are now weak ones - return Arrays.copyOfRange(result, 0, result.length - 2); + // The last 4 etypes are now weak ones + return Arrays.copyOfRange(result, 0, result.length - 4); } return result; } diff --git a/jdk/test/sun/security/krb5/auto/NewSalt.java b/jdk/test/sun/security/krb5/auto/NewSalt.java index 6101ebf89a1..35107cf4c48 100644 --- a/jdk/test/sun/security/krb5/auto/NewSalt.java +++ b/jdk/test/sun/security/krb5/auto/NewSalt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public static void main(String[] args) KDC kdc = new OneKDC(null); if (System.getProperty("onlyonepreauth") != null) { KDC.saveConfig(OneKDC.KRB5_CONF, kdc, - "default_tgs_enctypes=des3-cbc-sha1"); + "default_tgs_enctypes=aes128-cts"); Config.refresh(); kdc.setOption(KDC.Option.ONLY_ONE_PREAUTH, true); } diff --git a/jdk/test/sun/security/krb5/auto/W83.java b/jdk/test/sun/security/krb5/auto/W83.java index 9b30db75c19..559704875e2 100644 --- a/jdk/test/sun/security/krb5/auto/W83.java +++ b/jdk/test/sun/security/krb5/auto/W83.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,11 +26,11 @@ * @bug 6932525 6951366 6959292 * @summary kerberos login failure on win2008 with AD set to win2000 compat mode * and cannot login if session key and preauth does not use the same etype + * @compile -XDignore.symbol.file W83.java * @run main/othervm -Dsun.net.spi.nameservice.provider.1=ns,mock -D6932525 W83 * @run main/othervm -Dsun.net.spi.nameservice.provider.1=ns,mock -D6959292 W83 */ import com.sun.security.auth.module.Krb5LoginModule; -import java.io.File; import sun.security.krb5.Config; import sun.security.krb5.EncryptedData; import sun.security.krb5.PrincipalName; @@ -47,7 +47,8 @@ public static void main(String[] args) throws Exception { KDC kdc = new KDC(OneKDC.REALM, "127.0.0.1", 0, true); kdc.addPrincipal(OneKDC.USER, OneKDC.PASS); kdc.addPrincipalRandKey("krbtgt/" + OneKDC.REALM); - KDC.saveConfig(OneKDC.KRB5_CONF, kdc); + KDC.saveConfig(OneKDC.KRB5_CONF, kdc, + "allow_weak_crypto = true"); System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF); Config.refresh(); diff --git a/jdk/test/sun/security/krb5/etype/WeakCrypto.java b/jdk/test/sun/security/krb5/etype/WeakCrypto.java index e7a109f6f33..adec7d5aa4f 100644 --- a/jdk/test/sun/security/krb5/etype/WeakCrypto.java +++ b/jdk/test/sun/security/krb5/etype/WeakCrypto.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,41 +22,59 @@ */ /* * @test - * @bug 6844909 8012679 + * @bug 6844909 8012679 8139348 * @run main/othervm WeakCrypto * @run main/othervm WeakCrypto true * @run main/othervm WeakCrypto false * @summary support allow_weak_crypto in krb5.conf */ -import java.io.File; import java.lang.Exception; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import sun.security.krb5.EncryptionKey; import sun.security.krb5.internal.crypto.EType; import sun.security.krb5.EncryptedData; public class WeakCrypto { + + static List weakOnes = Arrays.asList( + EncryptedData.ETYPE_DES_CBC_CRC, + EncryptedData.ETYPE_DES_CBC_MD5, + EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD, + EncryptedData.ETYPE_ARCFOUR_HMAC + ); + public static void main(String[] args) throws Exception { + String conf = "[libdefaults]\n" + (args.length > 0 ? ("allow_weak_crypto = " + args[0]) : ""); Files.write(Paths.get("krb5.conf"), conf.getBytes()); System.setProperty("java.security.krb5.conf", "krb5.conf"); - boolean expected = args.length != 0 && args[0].equals("true"); - int[] etypes = EType.getBuiltInDefaults(); + // expected number of supported weak etypes + int expected = 0; + if (args.length != 0 && args[0].equals("true")) { + expected = weakOnes.size(); + } - boolean found = false; - for (int i=0, length = etypes.length; i