提交 85ccacb3 编写于 作者: W weijun

8226719: Kerberos login to Windows 2000 failed with "Inappropriate type of checksum in message"

Reviewed-by: xuelei
上级 7da40a32
......@@ -193,6 +193,26 @@ public class Checksum {
usage);
}
// =============== ATTENTION! Use with care ==================
// According to https://tools.ietf.org/html/rfc3961#section-6.1,
// An unkeyed checksum should only be used "in limited circumstances
// where the lack of a key does not provide a window for an attack,
// preferably as part of an encrypted message".
public boolean verifyAnyChecksum(byte[] data, EncryptionKey key,
int usage)
throws KdcErrException, KrbCryptoException {
CksumType cksumEngine = CksumType.getInstance(cksumType);
if (!cksumEngine.isSafe()) {
return cksumEngine.verifyChecksum(data, checksum);
} else {
return cksumEngine.verifyKeyedChecksum(data,
data.length,
key.getBytes(),
checksum,
usage);
}
}
/*
public Checksum(byte[] data) throws KdcErrException, KrbCryptoException {
this(Checksum.CKSUMTYPE_DEFAULT, data);
......
......@@ -143,8 +143,10 @@ abstract class KrbKdcRep {
Checksum repCksum = new Checksum(
new DerInputStream(
pa.getValue()).getDerValue());
// The checksum is inside encKDCRepPart so we don't
// care if it's keyed or not.
repPaReqEncPaRepValid =
repCksum.verifyKeyedChecksum(
repCksum.verifyAnyChecksum(
req.asn1Encode(), replyKey,
KeyUsage.KU_AS_REQ);
} catch (Exception e) {
......
......@@ -156,6 +156,11 @@ public abstract class CksumType {
public abstract byte[] calculateKeyedChecksum(byte[] data, int size,
byte[] key, int usage) throws KrbCryptoException;
public boolean verifyChecksum(byte[] data, byte[] checksum)
throws KrbCryptoException {
throw new UnsupportedOperationException("Not supported");
}
public abstract boolean verifyKeyedChecksum(byte[] data, int size,
byte[] key, byte[] checksum, int usage) throws KrbCryptoException;
......
......@@ -101,4 +101,14 @@ public final class RsaMd5CksumType extends CksumType {
return false;
}
@Override
public boolean verifyChecksum(byte[] data, byte[] checksum)
throws KrbCryptoException {
try {
byte[] calculated = MessageDigest.getInstance("MD5").digest(data);
return CksumType.isChecksumEqual(calculated, checksum);
} catch (Exception e) {
return false;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册