src/java.base/share/classes/com/sun/crypto/provider/PBES2Parameters.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 34687 jdk/src/java.base/share/classes/com/sun/crypto/provider/PBES2Parameters.java@d302ed125dc9
child 51142 69dc9ea17b33
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14405
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
     1
/*
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
     4
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    10
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    15
 * accompanied this code).
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    16
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    20
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    23
 * questions.
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    24
 */
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    25
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    26
package com.sun.crypto.provider;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    27
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    28
import java.io.*;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    29
import java.math.BigInteger;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    30
import java.security.NoSuchAlgorithmException;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    31
import java.security.AlgorithmParametersSpi;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    32
import java.security.spec.AlgorithmParameterSpec;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    33
import java.security.spec.InvalidParameterSpecException;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    34
import javax.crypto.spec.IvParameterSpec;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    35
import javax.crypto.spec.PBEParameterSpec;
34687
d302ed125dc9 8144995: Move sun.misc.HexDumpEncoder to sun.security.util
chegar
parents: 27804
diff changeset
    36
import sun.security.util.HexDumpEncoder;
14405
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    37
import sun.security.util.*;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    38
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    39
/**
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    40
 * This class implements the parameter set used with password-based
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    41
 * encryption scheme 2 (PBES2), which is defined in PKCS#5 as follows:
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    42
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    43
 * <pre>
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    44
 * -- PBES2
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    45
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    46
 * PBES2Algorithms ALGORITHM-IDENTIFIER ::=
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    47
 *   { {PBES2-params IDENTIFIED BY id-PBES2}, ...}
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    48
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    49
 * id-PBES2 OBJECT IDENTIFIER ::= {pkcs-5 13}
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    50
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    51
 * PBES2-params ::= SEQUENCE {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    52
 *   keyDerivationFunc AlgorithmIdentifier {{PBES2-KDFs}},
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    53
 *   encryptionScheme AlgorithmIdentifier {{PBES2-Encs}} }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    54
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    55
 * PBES2-KDFs ALGORITHM-IDENTIFIER ::=
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    56
 *   { {PBKDF2-params IDENTIFIED BY id-PBKDF2}, ... }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    57
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    58
 * PBES2-Encs ALGORITHM-IDENTIFIER ::= { ... }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    59
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    60
 * -- PBKDF2
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    61
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    62
 * PBKDF2Algorithms ALGORITHM-IDENTIFIER ::=
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    63
 *   { {PBKDF2-params IDENTIFIED BY id-PBKDF2}, ...}
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    64
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    65
 * id-PBKDF2 OBJECT IDENTIFIER ::= {pkcs-5 12}
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    66
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    67
 * PBKDF2-params ::= SEQUENCE {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    68
 *     salt CHOICE {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    69
 *       specified OCTET STRING,
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    70
 *       otherSource AlgorithmIdentifier {{PBKDF2-SaltSources}}
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    71
 *     },
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    72
 *     iterationCount INTEGER (1..MAX),
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    73
 *     keyLength INTEGER (1..MAX) OPTIONAL,
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    74
 *     prf AlgorithmIdentifier {{PBKDF2-PRFs}} DEFAULT algid-hmacWithSHA1
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    75
 * }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    76
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    77
 * PBKDF2-SaltSources ALGORITHM-IDENTIFIER ::= { ... }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    78
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    79
 * PBKDF2-PRFs ALGORITHM-IDENTIFIER ::= {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    80
 *     {NULL IDENTIFIED BY id-hmacWithSHA1} |
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    81
 *     {NULL IDENTIFIED BY id-hmacWithSHA224} |
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    82
 *     {NULL IDENTIFIED BY id-hmacWithSHA256} |
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    83
 *     {NULL IDENTIFIED BY id-hmacWithSHA384} |
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    84
 *     {NULL IDENTIFIED BY id-hmacWithSHA512}, ... }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    85
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    86
 * algid-hmacWithSHA1 AlgorithmIdentifier {{PBKDF2-PRFs}} ::=
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    87
 *     {algorithm id-hmacWithSHA1, parameters NULL : NULL}
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    88
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    89
 * id-hmacWithSHA1 OBJECT IDENTIFIER ::= {digestAlgorithm 7}
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    90
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    91
 * PBES2-Encs ALGORITHM-IDENTIFIER ::= { ... }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    92
 *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    93
 * </pre>
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    94
 */
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    95
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    96
abstract class PBES2Parameters extends AlgorithmParametersSpi {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    97
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    98
    private static final int pkcs5PBKDF2[] =
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
    99
                                        {1, 2, 840, 113549, 1, 5, 12};
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   100
    private static final int pkcs5PBES2[] =
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   101
                                        {1, 2, 840, 113549, 1, 5, 13};
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   102
    private static final int hmacWithSHA1[] =
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   103
                                        {1, 2, 840, 113549, 2, 7};
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   104
    private static final int hmacWithSHA224[] =
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   105
                                        {1, 2, 840, 113549, 2, 8};
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   106
    private static final int hmacWithSHA256[] =
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   107
                                        {1, 2, 840, 113549, 2, 9};
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   108
    private static final int hmacWithSHA384[] =
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   109
                                        {1, 2, 840, 113549, 2, 10};
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   110
    private static final int hmacWithSHA512[] =
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   111
                                        {1, 2, 840, 113549, 2, 11};
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   112
    private static final int aes128CBC[] =
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   113
                                        {2, 16, 840, 1, 101, 3, 4, 1, 2};
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   114
    private static final int aes192CBC[] =
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   115
                                        {2, 16, 840, 1, 101, 3, 4, 1, 22};
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   116
    private static final int aes256CBC[] =
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   117
                                        {2, 16, 840, 1, 101, 3, 4, 1, 42};
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   118
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   119
    private static ObjectIdentifier pkcs5PBKDF2_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   120
    private static ObjectIdentifier pkcs5PBES2_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   121
    private static ObjectIdentifier hmacWithSHA1_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   122
    private static ObjectIdentifier hmacWithSHA224_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   123
    private static ObjectIdentifier hmacWithSHA256_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   124
    private static ObjectIdentifier hmacWithSHA384_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   125
    private static ObjectIdentifier hmacWithSHA512_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   126
    private static ObjectIdentifier aes128CBC_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   127
    private static ObjectIdentifier aes192CBC_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   128
    private static ObjectIdentifier aes256CBC_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   129
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   130
    static {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   131
        try {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   132
            pkcs5PBKDF2_OID = new ObjectIdentifier(pkcs5PBKDF2);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   133
            pkcs5PBES2_OID = new ObjectIdentifier(pkcs5PBES2);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   134
            hmacWithSHA1_OID = new ObjectIdentifier(hmacWithSHA1);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   135
            hmacWithSHA224_OID = new ObjectIdentifier(hmacWithSHA224);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   136
            hmacWithSHA256_OID = new ObjectIdentifier(hmacWithSHA256);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   137
            hmacWithSHA384_OID = new ObjectIdentifier(hmacWithSHA384);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   138
            hmacWithSHA512_OID = new ObjectIdentifier(hmacWithSHA512);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   139
            aes128CBC_OID = new ObjectIdentifier(aes128CBC);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   140
            aes192CBC_OID = new ObjectIdentifier(aes192CBC);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   141
            aes256CBC_OID = new ObjectIdentifier(aes256CBC);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   142
        } catch (IOException ioe) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   143
            // should not happen
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   144
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   145
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   146
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   147
    // the PBES2 algorithm name
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   148
    private String pbes2AlgorithmName = null;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   149
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   150
    // the salt
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   151
    private byte[] salt = null;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   152
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   153
    // the iteration count
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   154
    private int iCount = 0;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   155
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   156
    // the cipher parameter
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   157
    private AlgorithmParameterSpec cipherParam = null;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   158
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   159
    // the key derivation function (default is HmacSHA1)
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   160
    private ObjectIdentifier kdfAlgo_OID = hmacWithSHA1_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   161
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   162
    // the encryption function
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   163
    private ObjectIdentifier cipherAlgo_OID = null;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   164
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   165
    // the cipher keysize (in bits)
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   166
    private int keysize = -1;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   167
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   168
    PBES2Parameters() {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   169
        // KDF, encryption & keysize values are set later, in engineInit(byte[])
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   170
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   171
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   172
    PBES2Parameters(String pbes2AlgorithmName) throws NoSuchAlgorithmException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   173
        int and;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   174
        String kdfAlgo = null;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   175
        String cipherAlgo = null;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   176
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   177
        // Extract the KDF and encryption algorithm names
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   178
        this.pbes2AlgorithmName = pbes2AlgorithmName;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   179
        if (pbes2AlgorithmName.startsWith("PBEWith") &&
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   180
            (and = pbes2AlgorithmName.indexOf("And", 7 + 1)) > 0) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   181
            kdfAlgo = pbes2AlgorithmName.substring(7, and);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   182
            cipherAlgo = pbes2AlgorithmName.substring(and + 3);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   183
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   184
            // Check for keysize
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   185
            int underscore;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   186
            if ((underscore = cipherAlgo.indexOf('_')) > 0) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   187
                int slash;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   188
                if ((slash = cipherAlgo.indexOf('/', underscore + 1)) > 0) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   189
                    keysize =
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   190
                        Integer.parseInt(cipherAlgo.substring(underscore + 1,
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   191
                            slash));
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   192
                } else {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   193
                    keysize =
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   194
                        Integer.parseInt(cipherAlgo.substring(underscore + 1));
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   195
                }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   196
                cipherAlgo = cipherAlgo.substring(0, underscore);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   197
            }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   198
        } else {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   199
            throw new NoSuchAlgorithmException("No crypto implementation for " +
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   200
                pbes2AlgorithmName);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   201
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   202
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   203
        switch (kdfAlgo) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   204
        case "HmacSHA1":
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   205
            kdfAlgo_OID = hmacWithSHA1_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   206
            break;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   207
        case "HmacSHA224":
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   208
            kdfAlgo_OID = hmacWithSHA224_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   209
            break;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   210
        case "HmacSHA256":
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   211
            kdfAlgo_OID = hmacWithSHA256_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   212
            break;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   213
        case "HmacSHA384":
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   214
            kdfAlgo_OID = hmacWithSHA384_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   215
            break;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   216
        case "HmacSHA512":
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   217
            kdfAlgo_OID = hmacWithSHA512_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   218
            break;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   219
        default:
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   220
            throw new NoSuchAlgorithmException(
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   221
                "No crypto implementation for " + kdfAlgo);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   222
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   223
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   224
        if (cipherAlgo.equals("AES")) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   225
            this.keysize = keysize;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   226
            switch (keysize) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   227
            case 128:
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   228
                cipherAlgo_OID = aes128CBC_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   229
                break;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   230
            case 256:
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   231
                cipherAlgo_OID = aes256CBC_OID;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   232
                break;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   233
            default:
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   234
                throw new NoSuchAlgorithmException(
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   235
                    "No Cipher implementation for " + keysize + "-bit " +
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   236
                        cipherAlgo);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   237
            }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   238
        } else {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   239
            throw new NoSuchAlgorithmException("No Cipher implementation for " +
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   240
                cipherAlgo);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   241
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   242
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   243
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   244
    protected void engineInit(AlgorithmParameterSpec paramSpec)
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   245
        throws InvalidParameterSpecException
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   246
    {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   247
       if (!(paramSpec instanceof PBEParameterSpec)) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   248
           throw new InvalidParameterSpecException
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   249
               ("Inappropriate parameter specification");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   250
       }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   251
       this.salt = ((PBEParameterSpec)paramSpec).getSalt().clone();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   252
       this.iCount = ((PBEParameterSpec)paramSpec).getIterationCount();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   253
       this.cipherParam = ((PBEParameterSpec)paramSpec).getParameterSpec();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   254
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   255
27804
4659e70271c4 8066617: Suppress deprecation warnings in java.base module
darcy
parents: 25859
diff changeset
   256
    @SuppressWarnings("deprecation")
14405
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   257
    protected void engineInit(byte[] encoded)
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   258
        throws IOException
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   259
    {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   260
        String kdfAlgo = null;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   261
        String cipherAlgo = null;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   262
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   263
        DerValue pBES2Algorithms = new DerValue(encoded);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   264
        if (pBES2Algorithms.tag != DerValue.tag_Sequence) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   265
            throw new IOException("PBE parameter parsing error: "
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   266
                                  + "not an ASN.1 SEQUENCE tag");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   267
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   268
        if (!pkcs5PBES2_OID.equals(pBES2Algorithms.data.getOID())) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   269
            throw new IOException("PBE parameter parsing error: "
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   270
                + "expecting the object identifier for PBES2");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   271
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   272
        if (pBES2Algorithms.tag != DerValue.tag_Sequence) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   273
            throw new IOException("PBE parameter parsing error: "
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   274
                + "not an ASN.1 SEQUENCE tag");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   275
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   276
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   277
        DerValue pBES2_params = pBES2Algorithms.data.getDerValue();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   278
        if (pBES2_params.tag != DerValue.tag_Sequence) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   279
            throw new IOException("PBE parameter parsing error: "
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   280
                + "not an ASN.1 SEQUENCE tag");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   281
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   282
        kdfAlgo = parseKDF(pBES2_params.data.getDerValue());
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   283
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   284
        if (pBES2_params.tag != DerValue.tag_Sequence) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   285
            throw new IOException("PBE parameter parsing error: "
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   286
                + "not an ASN.1 SEQUENCE tag");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   287
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   288
        cipherAlgo = parseES(pBES2_params.data.getDerValue());
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   289
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   290
        pbes2AlgorithmName = new StringBuilder().append("PBEWith")
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   291
            .append(kdfAlgo).append("And").append(cipherAlgo).toString();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   292
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   293
27804
4659e70271c4 8066617: Suppress deprecation warnings in java.base module
darcy
parents: 25859
diff changeset
   294
    @SuppressWarnings("deprecation")
14405
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   295
    private String parseKDF(DerValue keyDerivationFunc) throws IOException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   296
        String kdfAlgo = null;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   297
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   298
        if (!pkcs5PBKDF2_OID.equals(keyDerivationFunc.data.getOID())) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   299
            throw new IOException("PBE parameter parsing error: "
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   300
                + "expecting the object identifier for PBKDF2");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   301
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   302
        if (keyDerivationFunc.tag != DerValue.tag_Sequence) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   303
            throw new IOException("PBE parameter parsing error: "
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   304
                + "not an ASN.1 SEQUENCE tag");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   305
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   306
        DerValue pBKDF2_params = keyDerivationFunc.data.getDerValue();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   307
        if (pBKDF2_params.tag != DerValue.tag_Sequence) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   308
            throw new IOException("PBE parameter parsing error: "
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   309
                + "not an ASN.1 SEQUENCE tag");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   310
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   311
        DerValue specified = pBKDF2_params.data.getDerValue();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   312
        // the 'specified' ASN.1 CHOICE for 'salt' is supported
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   313
        if (specified.tag == DerValue.tag_OctetString) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   314
            salt = specified.getOctetString();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   315
        } else {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   316
            // the 'otherSource' ASN.1 CHOICE for 'salt' is not supported
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   317
            throw new IOException("PBE parameter parsing error: "
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   318
                + "not an ASN.1 OCTET STRING tag");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   319
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   320
        iCount = pBKDF2_params.data.getInteger();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   321
        DerValue keyLength = pBKDF2_params.data.getDerValue();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   322
        if (keyLength.tag == DerValue.tag_Integer) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   323
            keysize = keyLength.getInteger() * 8; // keysize (in bits)
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   324
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   325
        if (pBKDF2_params.tag == DerValue.tag_Sequence) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   326
            DerValue prf = pBKDF2_params.data.getDerValue();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   327
            kdfAlgo_OID = prf.data.getOID();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   328
            if (hmacWithSHA1_OID.equals(kdfAlgo_OID)) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   329
                kdfAlgo = "HmacSHA1";
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   330
            } else if (hmacWithSHA224_OID.equals(kdfAlgo_OID)) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   331
                kdfAlgo = "HmacSHA224";
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   332
            } else if (hmacWithSHA256_OID.equals(kdfAlgo_OID)) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   333
                kdfAlgo = "HmacSHA256";
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   334
            } else if (hmacWithSHA384_OID.equals(kdfAlgo_OID)) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   335
                kdfAlgo = "HmacSHA384";
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   336
            } else if (hmacWithSHA512_OID.equals(kdfAlgo_OID)) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   337
                kdfAlgo = "HmacSHA512";
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   338
            } else {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   339
                throw new IOException("PBE parameter parsing error: "
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   340
                    + "expecting the object identifier for a HmacSHA key "
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   341
                    + "derivation function");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   342
            }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   343
            if (prf.data.available() != 0) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   344
                // parameter is 'NULL' for all HmacSHA KDFs
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   345
                DerValue parameter = prf.data.getDerValue();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   346
                if (parameter.tag != DerValue.tag_Null) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   347
                    throw new IOException("PBE parameter parsing error: "
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   348
                        + "not an ASN.1 NULL tag");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   349
                }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   350
            }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   351
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   352
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   353
        return kdfAlgo;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   354
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   355
27804
4659e70271c4 8066617: Suppress deprecation warnings in java.base module
darcy
parents: 25859
diff changeset
   356
    @SuppressWarnings("deprecation")
14405
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   357
    private String parseES(DerValue encryptionScheme) throws IOException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   358
        String cipherAlgo = null;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   359
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   360
        cipherAlgo_OID = encryptionScheme.data.getOID();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   361
        if (aes128CBC_OID.equals(cipherAlgo_OID)) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   362
            cipherAlgo = "AES_128";
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   363
            // parameter is AES-IV 'OCTET STRING (SIZE(16))'
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   364
            cipherParam =
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   365
                new IvParameterSpec(encryptionScheme.data.getOctetString());
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   366
            keysize = 128;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   367
        } else if (aes256CBC_OID.equals(cipherAlgo_OID)) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   368
            cipherAlgo = "AES_256";
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   369
            // parameter is AES-IV 'OCTET STRING (SIZE(16))'
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   370
            cipherParam =
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   371
                new IvParameterSpec(encryptionScheme.data.getOctetString());
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   372
            keysize = 256;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   373
        } else {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   374
            throw new IOException("PBE parameter parsing error: "
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   375
                + "expecting the object identifier for AES cipher");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   376
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   377
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   378
        return cipherAlgo;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   379
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   380
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   381
    protected void engineInit(byte[] encoded, String decodingMethod)
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   382
        throws IOException
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   383
    {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   384
        engineInit(encoded);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   385
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   386
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   387
    protected <T extends AlgorithmParameterSpec>
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   388
            T engineGetParameterSpec(Class<T> paramSpec)
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   389
        throws InvalidParameterSpecException
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   390
    {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   391
        if (PBEParameterSpec.class.isAssignableFrom(paramSpec)) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   392
            return paramSpec.cast(
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   393
                new PBEParameterSpec(this.salt, this.iCount, this.cipherParam));
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   394
        } else {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   395
            throw new InvalidParameterSpecException
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   396
                ("Inappropriate parameter specification");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   397
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   398
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   399
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   400
    protected byte[] engineGetEncoded() throws IOException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   401
        DerOutputStream out = new DerOutputStream();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   402
        DerOutputStream pBES2Algorithms = new DerOutputStream();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   403
        pBES2Algorithms.putOID(pkcs5PBES2_OID);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   404
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   405
        DerOutputStream pBES2_params = new DerOutputStream();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   406
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   407
        DerOutputStream keyDerivationFunc = new DerOutputStream();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   408
        keyDerivationFunc.putOID(pkcs5PBKDF2_OID);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   409
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   410
        DerOutputStream pBKDF2_params = new DerOutputStream();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   411
        pBKDF2_params.putOctetString(salt); // choice: 'specified OCTET STRING'
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   412
        pBKDF2_params.putInteger(iCount);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   413
        pBKDF2_params.putInteger(keysize / 8); // derived key length (in octets)
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   414
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   415
        DerOutputStream prf = new DerOutputStream();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   416
        // algorithm is id-hmacWithSHA1/SHA224/SHA256/SHA384/SHA512
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   417
        prf.putOID(kdfAlgo_OID);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   418
        // parameters is 'NULL'
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   419
        prf.putNull();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   420
        pBKDF2_params.write(DerValue.tag_Sequence, prf);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   421
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   422
        keyDerivationFunc.write(DerValue.tag_Sequence, pBKDF2_params);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   423
        pBES2_params.write(DerValue.tag_Sequence, keyDerivationFunc);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   424
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   425
        DerOutputStream encryptionScheme = new DerOutputStream();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   426
        // algorithm is id-aes128-CBC or id-aes256-CBC
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   427
        encryptionScheme.putOID(cipherAlgo_OID);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   428
        // parameters is 'AES-IV ::= OCTET STRING (SIZE(16))'
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   429
        if (cipherParam != null && cipherParam instanceof IvParameterSpec) {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   430
            encryptionScheme.putOctetString(
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   431
                ((IvParameterSpec)cipherParam).getIV());
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   432
        } else {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   433
            throw new IOException("Wrong parameter type: IV expected");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   434
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   435
        pBES2_params.write(DerValue.tag_Sequence, encryptionScheme);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   436
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   437
        pBES2Algorithms.write(DerValue.tag_Sequence, pBES2_params);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   438
        out.write(DerValue.tag_Sequence, pBES2Algorithms);
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   439
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   440
        return out.toByteArray();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   441
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   442
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   443
    protected byte[] engineGetEncoded(String encodingMethod)
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   444
        throws IOException
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   445
    {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   446
        return engineGetEncoded();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   447
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   448
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   449
    /*
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   450
     * Returns a formatted string describing the parameters.
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   451
     *
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   452
     * The algorithn name pattern is: "PBEWith<prf>And<encryption>"
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   453
     * where <prf> is one of: HmacSHA1, HmacSHA224, HmacSHA256, HmacSHA384,
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   454
     * or HmacSHA512, and <encryption> is AES with a keysize suffix.
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   455
     */
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   456
    protected String engineToString() {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   457
        return pbes2AlgorithmName;
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   458
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   459
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   460
    public static final class General extends PBES2Parameters {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   461
        public General() throws NoSuchAlgorithmException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   462
            super();
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   463
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   464
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   465
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   466
    public static final class HmacSHA1AndAES_128 extends PBES2Parameters {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   467
        public HmacSHA1AndAES_128() throws NoSuchAlgorithmException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   468
            super("PBEWithHmacSHA1AndAES_128");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   469
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   470
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   471
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   472
    public static final class HmacSHA224AndAES_128 extends PBES2Parameters {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   473
        public HmacSHA224AndAES_128() throws NoSuchAlgorithmException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   474
            super("PBEWithHmacSHA224AndAES_128");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   475
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   476
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   477
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   478
    public static final class HmacSHA256AndAES_128 extends PBES2Parameters {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   479
        public HmacSHA256AndAES_128() throws NoSuchAlgorithmException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   480
            super("PBEWithHmacSHA256AndAES_128");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   481
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   482
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   483
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   484
    public static final class HmacSHA384AndAES_128 extends PBES2Parameters {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   485
        public HmacSHA384AndAES_128() throws NoSuchAlgorithmException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   486
            super("PBEWithHmacSHA384AndAES_128");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   487
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   488
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   489
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   490
    public static final class HmacSHA512AndAES_128 extends PBES2Parameters {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   491
        public HmacSHA512AndAES_128() throws NoSuchAlgorithmException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   492
            super("PBEWithHmacSHA512AndAES_128");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   493
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   494
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   495
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   496
    public static final class HmacSHA1AndAES_256 extends PBES2Parameters {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   497
        public HmacSHA1AndAES_256() throws NoSuchAlgorithmException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   498
            super("PBEWithHmacSHA1AndAES_256");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   499
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   500
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   501
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   502
    public static final class HmacSHA224AndAES_256 extends PBES2Parameters {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   503
        public HmacSHA224AndAES_256() throws NoSuchAlgorithmException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   504
            super("PBEWithHmacSHA224AndAES_256");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   505
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   506
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   507
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   508
    public static final class HmacSHA256AndAES_256 extends PBES2Parameters {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   509
        public HmacSHA256AndAES_256() throws NoSuchAlgorithmException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   510
            super("PBEWithHmacSHA256AndAES_256");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   511
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   512
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   513
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   514
    public static final class HmacSHA384AndAES_256 extends PBES2Parameters {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   515
        public HmacSHA384AndAES_256() throws NoSuchAlgorithmException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   516
            super("PBEWithHmacSHA384AndAES_256");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   517
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   518
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   519
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   520
    public static final class HmacSHA512AndAES_256 extends PBES2Parameters {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   521
        public HmacSHA512AndAES_256() throws NoSuchAlgorithmException {
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   522
            super("PBEWithHmacSHA512AndAES_256");
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   523
        }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   524
    }
e7fff80005c1 6383200: PBE: need new algorithm support in password based encryption
vinnie
parents:
diff changeset
   525
}