src/java.security.jgss/share/classes/sun/security/krb5/EncryptionKey.java
changeset 48651 67abfee27e69
parent 47216 71c04702a3d5
child 58331 e4ce29f6094e
equal deleted inserted replaced
48650:e7164f73c4d3 48651:67abfee27e69
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2017, 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
   249                 case EncryptedData.ETYPE_AES128_CTS_HMAC_SHA1_96:
   249                 case EncryptedData.ETYPE_AES128_CTS_HMAC_SHA1_96:
   250                         return Aes128.stringToKey(password, salt, s2kparams);
   250                         return Aes128.stringToKey(password, salt, s2kparams);
   251 
   251 
   252                 case EncryptedData.ETYPE_AES256_CTS_HMAC_SHA1_96:
   252                 case EncryptedData.ETYPE_AES256_CTS_HMAC_SHA1_96:
   253                         return Aes256.stringToKey(password, salt, s2kparams);
   253                         return Aes256.stringToKey(password, salt, s2kparams);
       
   254 
       
   255                 case EncryptedData.ETYPE_AES128_CTS_HMAC_SHA256_128:
       
   256                         return Aes128Sha2.stringToKey(password, salt, s2kparams);
       
   257 
       
   258                 case EncryptedData.ETYPE_AES256_CTS_HMAC_SHA384_192:
       
   259                     return Aes256Sha2.stringToKey(password, salt, s2kparams);
   254 
   260 
   255                 default:
   261                 default:
   256                         throw new IllegalArgumentException("encryption type " +
   262                         throw new IllegalArgumentException("encryption type " +
   257                         EType.toString(keyType) + " not supported");
   263                         EType.toString(keyType) + " not supported");
   258             }
   264             }
   291             // validate if AES256 is enabled
   297             // validate if AES256 is enabled
   292             if (!EType.isSupported(keyType)) {
   298             if (!EType.isSupported(keyType)) {
   293                 throw new IllegalArgumentException("Algorithm " + algorithm +
   299                 throw new IllegalArgumentException("Algorithm " + algorithm +
   294                         " not enabled");
   300                         " not enabled");
   295             }
   301             }
       
   302         } else if (algorithm.equalsIgnoreCase("aes128-cts-hmac-sha256-128")) {
       
   303             keyType = EncryptedData.ETYPE_AES128_CTS_HMAC_SHA256_128;
       
   304         } else if (algorithm.equalsIgnoreCase("aes256-cts-hmac-sha384-192")) {
       
   305             keyType = EncryptedData.ETYPE_AES256_CTS_HMAC_SHA384_192;
       
   306             // validate if AES256 is enabled
       
   307             if (!EType.isSupported(keyType)) {
       
   308                 throw new IllegalArgumentException("Algorithm " + algorithm +
       
   309                         " not enabled");
       
   310             }
   296         } else {
   311         } else {
   297             throw new IllegalArgumentException("Algorithm " + algorithm +
   312             throw new IllegalArgumentException("Algorithm " + algorithm +
   298                 " not supported");
   313                 " not supported");
   299         }
   314         }
   300 
   315