src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11ECDHKeyAgreement.java
author mbalao
Thu, 29 Nov 2018 13:36:23 -0300
changeset 53257 5170dc2bcf64
parent 47216 71c04702a3d5
permissions -rw-r--r--
6913047: Long term memory leak when using PKCS11 and JCE exceeds 32 bit process address space Summary: Extract cryptographic keys within NSS PKCS11 software tokens for memory management purposes. Reviewed-by: valeriep
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
53257
5170dc2bcf64 6913047: Long term memory leak when using PKCS11 and JCE exceeds 32 bit process address space
mbalao
parents: 47216
diff changeset
     2
 * Copyright (c) 2006, 2018, 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.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.security.interfaces.ECPublicKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.spec.AlgorithmParameterSpec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.crypto.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import static sun.security.pkcs11.TemplateManager.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.security.pkcs11.wrapper.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * KeyAgreement implementation for ECDH.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @author  Andreas Sterbenz
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @since   1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
final class P11ECDHKeyAgreement extends KeyAgreementSpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    // token instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private final Token token;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    // algorithm name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private final String algorithm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    // mechanism id
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private final long mechanism;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    // private key, if initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private P11Key privateKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    // encoded public point, non-null between doPhase() and generateSecret() only
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private byte[] publicValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    // length of the secret to be derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private int secretLen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    P11ECDHKeyAgreement(Token token, String algorithm, long mechanism) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        this.token = token;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        this.algorithm = algorithm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        this.mechanism = mechanism;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    // see JCE spec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    protected void engineInit(Key key, SecureRandom random)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        if (key instanceof PrivateKey == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            throw new InvalidKeyException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                        ("Key must be instance of PrivateKey");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        privateKey = P11KeyFactory.convertKey(token, key, "EC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        publicValue = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    // see JCE spec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    protected void engineInit(Key key, AlgorithmParameterSpec params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            SecureRandom random) throws InvalidKeyException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            InvalidAlgorithmParameterException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        if (params != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            throw new InvalidAlgorithmParameterException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                        ("Parameters not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        engineInit(key, random);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    // see JCE spec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    protected Key engineDoPhase(Key key, boolean lastPhase)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            throws InvalidKeyException, IllegalStateException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        if (privateKey == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            throw new IllegalStateException("Not initialized");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        if (publicValue != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            throw new IllegalStateException("Phase already executed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        if (lastPhase == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            throw new IllegalStateException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                ("Only two party agreement supported, lastPhase must be true");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        if (key instanceof ECPublicKey == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            throw new InvalidKeyException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                ("Key must be a PublicKey with algorithm EC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        ECPublicKey ecKey = (ECPublicKey)key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        int keyLenBits = ecKey.getParams().getCurve().getField().getFieldSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        secretLen = (keyLenBits + 7) >> 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        publicValue = P11ECKeyFactory.getEncodedPublicValue(ecKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    // see JCE spec
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    protected byte[] engineGenerateSecret() throws IllegalStateException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        if ((privateKey == null) || (publicValue == null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            throw new IllegalStateException("Not initialized correctly");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        Session session = null;
53257
5170dc2bcf64 6913047: Long term memory leak when using PKCS11 and JCE exceeds 32 bit process address space
mbalao
parents: 47216
diff changeset
   123
        long privKeyID = privateKey.getKeyID();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            session = token.getOpSession();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                new CK_ATTRIBUTE(CKA_CLASS, CKO_SECRET_KEY),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                new CK_ATTRIBUTE(CKA_KEY_TYPE, CKK_GENERIC_SECRET),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            CK_ECDH1_DERIVE_PARAMS ckParams =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                    new CK_ECDH1_DERIVE_PARAMS(CKD_NULL, null, publicValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            attributes = token.getAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                (O_GENERATE, CKO_SECRET_KEY, CKK_GENERIC_SECRET, attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            long keyID = token.p11.C_DeriveKey(session.id(),
53257
5170dc2bcf64 6913047: Long term memory leak when using PKCS11 and JCE exceeds 32 bit process address space
mbalao
parents: 47216
diff changeset
   135
                    new CK_MECHANISM(mechanism, ckParams), privKeyID,
5170dc2bcf64 6913047: Long term memory leak when using PKCS11 and JCE exceeds 32 bit process address space
mbalao
parents: 47216
diff changeset
   136
                    attributes);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            attributes = new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                new CK_ATTRIBUTE(CKA_VALUE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            token.p11.C_GetAttributeValue(session.id(), keyID, attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            byte[] secret = attributes[0].getByteArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            token.p11.C_DestroyObject(session.id(), keyID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            return secret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        } catch (PKCS11Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            throw new ProviderException("Could not derive key", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        } finally {
53257
5170dc2bcf64 6913047: Long term memory leak when using PKCS11 and JCE exceeds 32 bit process address space
mbalao
parents: 47216
diff changeset
   147
            privateKey.releaseKeyID();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            publicValue = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            token.releaseSession(session);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    // see JCE spec
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    protected int engineGenerateSecret(byte[] sharedSecret, int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            offset) throws IllegalStateException, ShortBufferException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        if (offset + secretLen > sharedSecret.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            throw new ShortBufferException("Need " + secretLen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                + " bytes, only " + (sharedSecret.length - offset) + " available");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        byte[] secret = engineGenerateSecret();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        System.arraycopy(secret, 0, sharedSecret, offset, secret.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        return secret.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    // see JCE spec
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    protected SecretKey engineGenerateSecret(String algorithm)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            throws IllegalStateException, NoSuchAlgorithmException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        if (algorithm == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            throw new NoSuchAlgorithmException("Algorithm must not be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        if (algorithm.equals("TlsPremasterSecret") == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            throw new NoSuchAlgorithmException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                ("Only supported for algorithm TlsPremasterSecret");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        return nativeGenerateSecret(algorithm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    private SecretKey nativeGenerateSecret(String algorithm)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            throws IllegalStateException, NoSuchAlgorithmException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        if ((privateKey == null) || (publicValue == null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            throw new IllegalStateException("Not initialized correctly");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        long keyType = CKK_GENERIC_SECRET;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        Session session = null;
53257
5170dc2bcf64 6913047: Long term memory leak when using PKCS11 and JCE exceeds 32 bit process address space
mbalao
parents: 47216
diff changeset
   187
        long privKeyID = privateKey.getKeyID();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            session = token.getObjSession();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                new CK_ATTRIBUTE(CKA_CLASS, CKO_SECRET_KEY),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                new CK_ATTRIBUTE(CKA_KEY_TYPE, keyType),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            CK_ECDH1_DERIVE_PARAMS ckParams =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                    new CK_ECDH1_DERIVE_PARAMS(CKD_NULL, null, publicValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            attributes = token.getAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                (O_GENERATE, CKO_SECRET_KEY, keyType, attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            long keyID = token.p11.C_DeriveKey(session.id(),
53257
5170dc2bcf64 6913047: Long term memory leak when using PKCS11 and JCE exceeds 32 bit process address space
mbalao
parents: 47216
diff changeset
   199
                    new CK_MECHANISM(mechanism, ckParams), privKeyID,
5170dc2bcf64 6913047: Long term memory leak when using PKCS11 and JCE exceeds 32 bit process address space
mbalao
parents: 47216
diff changeset
   200
                    attributes);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            CK_ATTRIBUTE[] lenAttributes = new CK_ATTRIBUTE[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                new CK_ATTRIBUTE(CKA_VALUE_LEN),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            token.p11.C_GetAttributeValue(session.id(), keyID, lenAttributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            int keyLen = (int)lenAttributes[0].getLong();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            SecretKey key = P11Key.secretKey
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                        (session, keyID, algorithm, keyLen << 3, attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            return key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        } catch (PKCS11Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            throw new InvalidKeyException("Could not derive key", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        } finally {
53257
5170dc2bcf64 6913047: Long term memory leak when using PKCS11 and JCE exceeds 32 bit process address space
mbalao
parents: 47216
diff changeset
   212
            privateKey.releaseKeyID();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            publicValue = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            token.releaseSession(session);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
}