jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsKeyMaterialGenerator.java
author sundar
Mon, 31 Aug 2015 17:51:02 +0530
changeset 32434 769b3d81ae69
parent 27936 ca9ee8e3d527
child 41123 66eaead2a150
permissions -rw-r--r--
8134731: Function.prototype.apply interacts incorrectly with arguments Reviewed-by: attila, hannesw
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
27936
ca9ee8e3d527 8066638: Suppress deprecation warnings in jdk.crypto module
darcy
parents: 25859
diff changeset
     2
 * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.security.pkcs11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.security.spec.AlgorithmParameterSpec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.crypto.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.crypto.spec.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.security.internal.spec.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.security.internal.interfaces.TlsMasterSecret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import static sun.security.pkcs11.TemplateManager.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.security.pkcs11.wrapper.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * KeyGenerator to calculate the SSL/TLS key material (cipher keys and ivs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * mac keys) from the master secret.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @author  Andreas Sterbenz
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @since   1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
public final class P11TlsKeyMaterialGenerator extends KeyGeneratorSpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private final static String MSG = "TlsKeyMaterialGenerator must be "
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        + "initialized using a TlsKeyMaterialParameterSpec";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    // token instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private final Token token;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    // algorithm name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private final String algorithm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    // mechanism id
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private long mechanism;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    // parameter spec
27936
ca9ee8e3d527 8066638: Suppress deprecation warnings in jdk.crypto module
darcy
parents: 25859
diff changeset
    65
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private TlsKeyMaterialParameterSpec spec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    // master secret as a P11Key
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private P11Key p11Key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    // version, e.g. 0x0301
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private int version;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    P11TlsKeyMaterialGenerator(Token token, String algorithm, long mechanism)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            throws PKCS11Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        this.token = token;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        this.algorithm = algorithm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        this.mechanism = mechanism;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    protected void engineInit(SecureRandom random) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        throw new InvalidParameterException(MSG);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
27936
ca9ee8e3d527 8066638: Suppress deprecation warnings in jdk.crypto module
darcy
parents: 25859
diff changeset
    86
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    protected void engineInit(AlgorithmParameterSpec params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            SecureRandom random) throws InvalidAlgorithmParameterException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        if (params instanceof TlsKeyMaterialParameterSpec == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            throw new InvalidAlgorithmParameterException(MSG);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        this.spec = (TlsKeyMaterialParameterSpec)params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            p11Key = P11SecretKeyFactory.convertKey
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                            (token, spec.getMasterSecret(), "TlsMasterSecret");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        } catch (InvalidKeyException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            throw new InvalidAlgorithmParameterException("init() failed", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        version = (spec.getMajorVersion() << 8) | spec.getMinorVersion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        if ((version < 0x0300) && (version > 0x0302)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            throw new InvalidAlgorithmParameterException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                    ("Only SSL 3.0, TLS 1.0, and TLS 1.1 are supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        // we assume the token supports both the CKM_SSL3_* and the CKM_TLS_*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        // mechanisms
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    protected void engineInit(int keysize, SecureRandom random) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        throw new InvalidParameterException(MSG);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
27936
ca9ee8e3d527 8066638: Suppress deprecation warnings in jdk.crypto module
darcy
parents: 25859
diff changeset
   112
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    protected SecretKey engineGenerateKey() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        if (spec == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            throw new IllegalStateException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                ("TlsKeyMaterialGenerator must be initialized");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        mechanism = (version == 0x0300) ? CKM_SSL3_KEY_AND_MAC_DERIVE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                                         : CKM_TLS_KEY_AND_MAC_DERIVE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        int macBits = spec.getMacKeyLength() << 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        int ivBits = spec.getIvLength() << 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        int expandedKeyBits = spec.getExpandedCipherKeyLength() << 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        int keyBits = spec.getCipherKeyLength() << 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        boolean isExportable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        if (expandedKeyBits != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            isExportable = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            isExportable = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            expandedKeyBits = keyBits;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        CK_SSL3_RANDOM_DATA random = new CK_SSL3_RANDOM_DATA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                            (spec.getClientRandom(), spec.getServerRandom());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        CK_SSL3_KEY_MAT_PARAMS params = new CK_SSL3_KEY_MAT_PARAMS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                            (macBits, keyBits, ivBits, isExportable, random);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        String cipherAlgorithm = spec.getCipherAlgorithm();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        long keyType = P11SecretKeyFactory.getKeyType(cipherAlgorithm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        if (keyType < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            if (keyBits != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                throw new ProviderException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                            ("Unknown algorithm: " + spec.getCipherAlgorithm());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                // NULL encryption ciphersuites
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                keyType = CKK_GENERIC_SECRET;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        Session session = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            session = token.getObjSession();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            CK_ATTRIBUTE[] attributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            if (keyBits != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                attributes = new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                    new CK_ATTRIBUTE(CKA_CLASS, CKO_SECRET_KEY),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                    new CK_ATTRIBUTE(CKA_KEY_TYPE, keyType),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                    new CK_ATTRIBUTE(CKA_VALUE_LEN, expandedKeyBits >> 3),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                // ciphersuites with NULL ciphers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                attributes = new CK_ATTRIBUTE[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            attributes = token.getAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                (O_GENERATE, CKO_SECRET_KEY, keyType, attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            // the returned keyID is a dummy, ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            long keyID = token.p11.C_DeriveKey(session.id(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                new CK_MECHANISM(mechanism, params), p11Key.keyID, attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            CK_SSL3_KEY_MAT_OUT out = params.pReturnedKeyMaterial;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            // Note that the MAC keys do not inherit all attributes from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            // template, but they do inherit the sensitive/extractable/token
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            // flags, which is all P11Key cares about.
16913
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16067
diff changeset
   174
            SecretKey clientMacKey, serverMacKey;
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16067
diff changeset
   175
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16067
diff changeset
   176
            // The MAC size may be zero for GCM mode.
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16067
diff changeset
   177
            //
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16067
diff changeset
   178
            // PKCS11 does not support GCM mode as the author made the comment,
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16067
diff changeset
   179
            // so the macBits is unlikely to be zero. It's only a place holder.
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16067
diff changeset
   180
            if (macBits != 0) {
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16067
diff changeset
   181
                clientMacKey = P11Key.secretKey
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                    (session, out.hClientMacSecret, "MAC", macBits, attributes);
16913
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16067
diff changeset
   183
                serverMacKey = P11Key.secretKey
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                    (session, out.hServerMacSecret, "MAC", macBits, attributes);
16913
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16067
diff changeset
   185
            } else {
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16067
diff changeset
   186
                clientMacKey = null;
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16067
diff changeset
   187
                serverMacKey = null;
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16067
diff changeset
   188
            }
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16067
diff changeset
   189
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            SecretKey clientCipherKey, serverCipherKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            if (keyBits != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                clientCipherKey = P11Key.secretKey(session, out.hClientKey,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                        cipherAlgorithm, expandedKeyBits, attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                serverCipherKey = P11Key.secretKey(session, out.hServerKey,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                        cipherAlgorithm, expandedKeyBits, attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                clientCipherKey = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                serverCipherKey = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            IvParameterSpec clientIv = (out.pIVClient == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                                    ? null : new IvParameterSpec(out.pIVClient);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            IvParameterSpec serverIv = (out.pIVServer == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                                    ? null : new IvParameterSpec(out.pIVServer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            return new TlsKeyMaterialSpec(clientMacKey, serverMacKey,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                    clientCipherKey, clientIv, serverCipherKey, serverIv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            throw new ProviderException("Could not generate key", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            token.releaseSession(session);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
}