src/java.security.jgss/share/classes/sun/security/krb5/internal/crypto/dk/AesDkCrypto.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
41 import sun.security.krb5.KrbCryptoException; |
41 import sun.security.krb5.KrbCryptoException; |
42 import sun.security.krb5.Confounder; |
42 import sun.security.krb5.Confounder; |
43 import sun.security.krb5.internal.crypto.KeyUsage; |
43 import sun.security.krb5.internal.crypto.KeyUsage; |
44 import java.util.Arrays; |
44 import java.util.Arrays; |
45 |
45 |
|
46 import static java.nio.charset.StandardCharsets.UTF_8; |
|
47 |
46 /** |
48 /** |
47 * This class provides the implementation of AES Encryption for Kerberos |
49 * This class provides the implementation of AES Encryption for Kerberos |
48 * as defined RFC 3962. |
50 * as defined RFC 3962. |
49 * http://www.ietf.org/rfc/rfc3962.txt |
51 * http://www.ietf.org/rfc/rfc3962.txt |
50 * |
52 * |
102 public byte[] stringToKey(char[] password, String salt, byte[] s2kparams) |
104 public byte[] stringToKey(char[] password, String salt, byte[] s2kparams) |
103 throws GeneralSecurityException { |
105 throws GeneralSecurityException { |
104 |
106 |
105 byte[] saltUtf8 = null; |
107 byte[] saltUtf8 = null; |
106 try { |
108 try { |
107 saltUtf8 = salt.getBytes("UTF-8"); |
109 saltUtf8 = salt.getBytes(UTF_8); |
108 return stringToKey(password, saltUtf8, s2kparams); |
110 return stringToKey(password, saltUtf8, s2kparams); |
109 } catch (Exception e) { |
111 } catch (Exception e) { |
110 return null; |
112 return null; |
111 } finally { |
113 } finally { |
112 if (saltUtf8 != null) { |
114 if (saltUtf8 != null) { |