APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.krb5

public Class Checksum

extends Object
Class Inheritance
Imports
java.util.Arrays, sun.security.util.*, sun.security.krb5.internal.*, sun.security.krb5.internal.crypto.*, java.io.IOException, java.math.BigInteger

This class encapsulates the concept of a Kerberos checksum.

Field Summary

Modifier and TypeField and Description
private byte[]
private int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
public
Checksum(byte[]
the byte array of checksum.
data
,
int
the type of checksum.
new_cksumType
)

Constructs a new Checksum using the raw data and type.

public
Checksum(int
the type of checksum. If set to -1, the mandatory checksum type for the encryption type of key will be used
new_cksumType
,
byte[]
the data that needs to be performed a checksum calculation on
data
,
EncryptionKey
the key used by a keyed checksum
key
,
int
the usage used by a keyed checksum
usage
)

Constructs a new Checksum by calculating over the data using the specified checksum type.

public
Checksum(DerValue
a single DER-encoded value.
encoding
)

Constructs an instance of Checksum from an ASN.1 encoded representation.

Method Summary

Modifier and TypeMethod and Description
public byte[]

Returns:

byte array of encoded Checksum.
asn1Encode
()

Encodes a Checksum object.

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public final byte[]
getBytes()

Returns the raw bytes of the checksum, not in ASN.1 encoded form.

public final int
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

pack-priv boolean
public static Checksum

Returns:

an instance of Checksum.
parse
(DerInputStream
the Der input stream value, which contains one or more marshaled value.
data
,
byte
tag number.
explicitTag
,
boolean
indicates if this data field is optional
optional
)

Parse (unmarshal) a checksum object from a DER input stream.

public boolean
verifyAnyChecksum(byte[] data, EncryptionKey key, int usage)

Verifies the checksum over the data passed in. The checksum might be a keyed or not.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

checksumback to summary
private byte[] checksum
cksumTypeback to summary
private int cksumType
CKSUMTYPE_CRC32back to summary
public static final int CKSUMTYPE_CRC32
CKSUMTYPE_DES_MACback to summary
public static final int CKSUMTYPE_DES_MAC
CKSUMTYPE_DES_MAC_Kback to summary
public static final int CKSUMTYPE_DES_MAC_K
CKSUMTYPE_HMAC_MD5_ARCFOURback to summary
public static final int CKSUMTYPE_HMAC_MD5_ARCFOUR
CKSUMTYPE_HMAC_SHA1_96_AES128back to summary
public static final int CKSUMTYPE_HMAC_SHA1_96_AES128
CKSUMTYPE_HMAC_SHA1_96_AES256back to summary
public static final int CKSUMTYPE_HMAC_SHA1_96_AES256
CKSUMTYPE_HMAC_SHA1_DES3_KDback to summary
public static final int CKSUMTYPE_HMAC_SHA1_DES3_KD
CKSUMTYPE_HMAC_SHA256_128_AES128back to summary
public static final int CKSUMTYPE_HMAC_SHA256_128_AES128
CKSUMTYPE_HMAC_SHA384_192_AES256back to summary
public static final int CKSUMTYPE_HMAC_SHA384_192_AES256
CKSUMTYPE_NULLback to summary
public static final int CKSUMTYPE_NULL
CKSUMTYPE_RSA_MD4back to summary
public static final int CKSUMTYPE_RSA_MD4
CKSUMTYPE_RSA_MD4_DESback to summary
public static final int CKSUMTYPE_RSA_MD4_DES
CKSUMTYPE_RSA_MD4_DES_Kback to summary
public static final int CKSUMTYPE_RSA_MD4_DES_K
CKSUMTYPE_RSA_MD5back to summary
public static final int CKSUMTYPE_RSA_MD5
CKSUMTYPE_RSA_MD5_DESback to summary
public static final int CKSUMTYPE_RSA_MD5_DES

Constructor Detail

Checksumback to summary
public Checksum(byte[] data, int new_cksumType)

Constructs a new Checksum using the raw data and type. This constructor is only used by Authenticator Checksum sun.security.jgss.krb5.InitialToken.OverloadedChecksum where the checksum type must be 0x8003 (see https://tools.ietf.org/html/rfc4121#section-4.1.1) and checksum field/value is used to convey service flags, channel bindings, and optional delegation information. This special type does NOT have a CksumType and has its own calculating and verification rules. It does has the same ASN.1 encoding though.

Parameters
data:byte[]

the byte array of checksum.

new_cksumType:int

the type of checksum.

Checksumback to summary
public Checksum(int new_cksumType, byte[] data, EncryptionKey key, int usage) throws KdcErrException, KrbApErrException, KrbCryptoException

Constructs a new Checksum by calculating over the data using the specified checksum type. If the checksum is unkeyed, key and usage are ignored.

Parameters
new_cksumType:int

the type of checksum. If set to -1, the mandatory checksum type for the encryption type of key will be used

data:byte[]

the data that needs to be performed a checksum calculation on

key:EncryptionKey

the key used by a keyed checksum

usage:int

the usage used by a keyed checksum

Checksumback to summary
public Checksum(DerValue encoding) throws Asn1Exception, IOException

Constructs an instance of Checksum from an ASN.1 encoded representation.

Parameters
encoding:DerValue

a single DER-encoded value.

Exceptions
Asn1Exception:
if an error occurs while decoding an ASN1 encoded data.
IOException:
if an I/O error occurs while reading encoded data.

Method Detail

asn1Encodeback to summary
public byte[] asn1Encode() throws Asn1Exception, IOException

Encodes a Checksum object.

Checksum    ::= SEQUENCE {
        cksumtype   [0] Int32,
        checksum    [1] OCTET STRING
}

This definition reflects the Network Working Group RFC 4120 specification available at http://www.ietf.org/rfc/rfc4120.txt.

Returns:byte[]

byte array of encoded Checksum.

Exceptions
Asn1Exception:
if an error occurs while decoding an ASN1 encoded data.
IOException:
if an I/O error occurs while reading encoded data.
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getBytesback to summary
public final byte[] getBytes()

Returns the raw bytes of the checksum, not in ASN.1 encoded form.

getTypeback to summary
public final int getType()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
isEqualback to summary
pack-priv boolean isEqual(Checksum cksum) throws KdcErrException
parseback to summary
public static Checksum parse(DerInputStream data, byte explicitTag, boolean optional) throws Asn1Exception, IOException

Parse (unmarshal) a checksum object from a DER input stream. This form parsing might be used when expanding a value which is part of a constructed sequence and uses explicitly tagged type.

Parameters
data:DerInputStream

the Der input stream value, which contains one or more marshaled value.

explicitTag:byte

tag number.

optional:boolean

indicates if this data field is optional

Returns:Checksum

an instance of Checksum.

Exceptions
Asn1Exception:
if an error occurs while decoding an ASN1 encoded data.
IOException:
if an I/O error occurs while reading encoded data.
verifyAnyChecksumback to summary
public boolean verifyAnyChecksum(byte[] data, EncryptionKey key, int usage) throws KdcErrException, KrbCryptoException

Verifies the checksum over the data passed in. The checksum might be a keyed or not. =============== 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".