2
|
1 |
/*
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3 |
*
|
|
4 |
* This code is free software; you can redistribute it and/or modify it
|
|
5 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
6 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
7 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
8 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
5506
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
21 |
* or visit www.oracle.com if you need additional information or have any
|
|
22 |
* questions.
|
2
|
23 |
*/
|
|
24 |
|
|
25 |
/*
|
|
26 |
* (C) Copyright IBM Corp. 1999 All Rights Reserved.
|
|
27 |
* Copyright 1997 The Open Group Research Institute. All rights reserved.
|
|
28 |
*/
|
|
29 |
|
|
30 |
package sun.security.krb5.internal.crypto;
|
|
31 |
|
|
32 |
import sun.security.krb5.Checksum;
|
|
33 |
import sun.security.krb5.KrbCryptoException;
|
|
34 |
import sun.security.krb5.internal.*;
|
|
35 |
import java.security.MessageDigest;
|
|
36 |
import java.security.Provider;
|
|
37 |
import java.security.Security;
|
|
38 |
|
|
39 |
public final class RsaMd5CksumType extends CksumType {
|
|
40 |
|
|
41 |
public RsaMd5CksumType() {
|
|
42 |
}
|
|
43 |
|
|
44 |
public int confounderSize() {
|
|
45 |
return 0;
|
|
46 |
}
|
|
47 |
|
|
48 |
public int cksumType() {
|
|
49 |
return Checksum.CKSUMTYPE_RSA_MD5;
|
|
50 |
}
|
|
51 |
|
|
52 |
public boolean isSafe() {
|
|
53 |
return false;
|
|
54 |
}
|
|
55 |
|
|
56 |
public int cksumSize() {
|
|
57 |
return 16;
|
|
58 |
}
|
|
59 |
|
|
60 |
public int keyType() {
|
|
61 |
return Krb5.KEYTYPE_NULL;
|
|
62 |
}
|
|
63 |
|
|
64 |
public int keySize() {
|
|
65 |
return 0;
|
|
66 |
}
|
|
67 |
|
|
68 |
/**
|
|
69 |
* Calculates checksum using MD5.
|
|
70 |
* @param data the data used to generate the checksum.
|
|
71 |
* @param size length of the data.
|
|
72 |
* @return the checksum.
|
|
73 |
*
|
|
74 |
* @modified by Yanni Zhang, 12/08/99.
|
|
75 |
*/
|
|
76 |
|
|
77 |
public byte[] calculateChecksum(byte[] data, int size) throws KrbCryptoException{
|
|
78 |
MessageDigest md5;
|
|
79 |
byte[] result = null;
|
|
80 |
try {
|
|
81 |
md5 = MessageDigest.getInstance("MD5");
|
|
82 |
} catch (Exception e) {
|
|
83 |
throw new KrbCryptoException("JCE provider may not be installed. " + e.getMessage());
|
|
84 |
}
|
|
85 |
try {
|
|
86 |
md5.update(data);
|
|
87 |
result = md5.digest();
|
|
88 |
} catch (Exception e) {
|
|
89 |
throw new KrbCryptoException(e.getMessage());
|
|
90 |
}
|
|
91 |
return result;
|
|
92 |
}
|
|
93 |
|
|
94 |
public byte[] calculateKeyedChecksum(byte[] data, int size,
|
|
95 |
byte[] key, int usage) throws KrbCryptoException {
|
|
96 |
return null;
|
|
97 |
}
|
|
98 |
|
|
99 |
public boolean verifyKeyedChecksum(byte[] data, int size,
|
|
100 |
byte[] key, byte[] checksum, int usage) throws KrbCryptoException {
|
|
101 |
return false;
|
|
102 |
}
|
|
103 |
|
|
104 |
}
|