blob: 0b2cd0dbd447c228fad802c314569a741c74c4ac [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
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
6 * published by the Free Software Foundation. Sun designates this
7 * particular file as subject to the "Classpath" exception as provided
8 * by Sun in the LICENSE file that accompanied this code.
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 *
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
22 * have any questions.
23 */
24
25/*
26 *
27 * (C) Copyright IBM Corp. 1999 All Rights Reserved.
28 * Copyright 1997 The Open Group Research Institute. All rights reserved.
29 */
30
31package sun.security.krb5.internal.crypto;
32
33import sun.security.krb5.internal.*;
34import sun.security.krb5.Checksum;
35import sun.security.krb5.EncryptedData;
36import sun.security.krb5.KrbCryptoException;
37import java.security.MessageDigest;
38import java.security.Provider;
39import java.security.Security;
40
41public final class DesCbcMd5EType extends DesCbcEType {
42
43 public DesCbcMd5EType() {
44 }
45
46 public int eType() {
47 return EncryptedData.ETYPE_DES_CBC_MD5;
48 }
49
50 public int minimumPadSize() {
51 return 0;
52 }
53
54 public int confounderSize() {
55 return 8;
56 }
57
58 public int checksumType() {
59 return Checksum.CKSUMTYPE_RSA_MD5;
60 }
61
62 public int checksumSize() {
63 return 16;
64 }
65
66 /**
67 * Calculates checksum using MD5.
68 * @param data the input data.
69 * @param size the length of data.
70 * @return the checksum.
71 *
72 * @modified by Yanni Zhang, 12/06/99.
73 */
74 protected byte[] calculateChecksum(byte[] data, int size)
75 throws KrbCryptoException {
76 MessageDigest md5 = null;
77 try {
78 md5 = MessageDigest.getInstance("MD5");
79 } catch (Exception e) {
80 throw new KrbCryptoException("JCE provider may not be installed. " + e.getMessage());
81 }
82 try {
83 md5.update(data);
84 return(md5.digest());
85 } catch (Exception e) {
86 throw new KrbCryptoException(e.getMessage());
87 }
88 }
89}