jdk/src/share/classes/sun/security/ssl/HandshakeHash.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2007 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
package sun.security.ssl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * Abstraction for the SSL/TLS hash of all handshake messages that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * maintained to verify the integrity of the negotiation. Internally,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * it consists of an MD5 and an SHA1 digest. They are used in the client
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * and server finished messages and in certificate verify messages (if sent).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * This class transparently deals with cloneable and non-cloneable digests.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
final class HandshakeHash {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    private final MessageDigest md5, sha;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     * Create a new HandshakeHash. needCertificateVerify indicates whether
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * a hash for the certificate verify message is required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    HandshakeHash(boolean needCertificateVerify) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        int n = needCertificateVerify ? 3 : 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
            md5 = CloneableDigest.getDigest("MD5", n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            sha = CloneableDigest.getDigest("SHA", n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        } catch (NoSuchAlgorithmException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            throw new RuntimeException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
                        ("Algorithm MD5 or SHA not available", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    void update(byte b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        md5.update(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        sha.update(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    void update(byte[] b, int offset, int len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        md5.update(b, offset, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        sha.update(b, offset, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * Reset the remaining digests. Note this does *not* reset the numbe of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * digest clones that can be obtained. Digests that have already been
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * cloned and are gone remain gone.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    void reset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        md5.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        sha.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Return a new MD5 digest updated with all data hashed so far.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    MessageDigest getMD5Clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        return cloneDigest(md5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Return a new SHA digest updated with all data hashed so far.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    MessageDigest getSHAClone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        return cloneDigest(sha);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private static MessageDigest cloneDigest(MessageDigest digest) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            return (MessageDigest)digest.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        } catch (CloneNotSupportedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            // cannot occur for digests generated via CloneableDigest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            throw new RuntimeException("Could not clone digest", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * A wrapper for MessageDigests that simulates cloning of non-cloneable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * digests. It uses the standard MessageDigest API and therefore can be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * transparently in place of a regular digest.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * Note that we extend the MessageDigest class directly rather than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * MessageDigestSpi. This works because MessageDigest was originally designed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * this way in the JDK 1.1 days which allows us to avoid creating an internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * It can be "cloned" a limited number of times, which is specified at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * construction time. This is achieved by internally maintaining n digests
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * in parallel. Consequently, it is only 1/n-th times as fast as the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * digest.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * Example:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 *   MessageDigest md = CloneableDigest.getDigest("SHA", 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 *   md.update(data1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 *   MessageDigest md2 = (MessageDigest)md.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 *   md2.update(data2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 *   byte[] d1 = md2.digest(); // digest of data1 || data2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 *   md.update(data3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 *   byte[] d2 = md.digest();  // digest of data1 || data3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * This class is not thread safe.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
final class CloneableDigest extends MessageDigest implements Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * The individual MessageDigests. Initially, all elements are non-null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * When clone() is called, the non-null element with the maximum index is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * returned and the array element set to null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * All non-null element are always in the same state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    private final MessageDigest[] digests;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    private CloneableDigest(MessageDigest digest, int n, String algorithm)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            throws NoSuchAlgorithmException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        super(algorithm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        digests = new MessageDigest[n];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        digests[0] = digest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        for (int i = 1; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            digests[i] = JsseJce.getMessageDigest(algorithm);
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * Return a MessageDigest for the given algorithm that can be cloned the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * specified number of times. If the default implementation supports
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * cloning, it is returned. Otherwise, an instance of this class is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    static MessageDigest getDigest(String algorithm, int n)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            throws NoSuchAlgorithmException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        MessageDigest digest = JsseJce.getMessageDigest(algorithm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            digest.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            // already cloneable, use it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            return digest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        } catch (CloneNotSupportedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            return new CloneableDigest(digest, n, algorithm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * Check if this object is still usable. If it has already been cloned the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * maximum number of times, there are no digests left and this object can no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * longer be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    private void checkState() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        // XXX handshaking currently doesn't stop updating hashes...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        // if (digests[0] == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        //     throw new IllegalStateException("no digests left");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        // }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    protected int engineGetDigestLength() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        checkState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        return digests[0].getDigestLength();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    protected void engineUpdate(byte b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        checkState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        for (int i = 0; (i < digests.length) && (digests[i] != null); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            digests[i].update(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    protected void engineUpdate(byte[] b, int offset, int len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        checkState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        for (int i = 0; (i < digests.length) && (digests[i] != null); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            digests[i].update(b, offset, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    protected byte[] engineDigest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        checkState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        byte[] digest = digests[0].digest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        digestReset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        return digest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    protected int engineDigest(byte[] buf, int offset, int len)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            throws DigestException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        checkState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        int n = digests[0].digest(buf, offset, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        digestReset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        return n;
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
     * Reset all digests after a digest() call. digests[0] has already been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * implicitly reset by the digest() call and does not need to be reset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * again.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    private void digestReset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        for (int i = 1; (i < digests.length) && (digests[i] != null); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            digests[i].reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    protected void engineReset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        checkState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        for (int i = 0; (i < digests.length) && (digests[i] != null); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            digests[i].reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    public Object clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        checkState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        for (int i = digests.length - 1; i >= 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            if (digests[i] != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                MessageDigest digest = digests[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                digests[i] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                return digest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        // cannot occur
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        throw new InternalError();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
}