class DigestMD5Base.DigestIntegrity extends java.lang.Object implements SecurityCtx
Further details on the integrity-protection mechanism can be found at section 2.3 - Integrity protection in the RFC2831 definition.
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
CLIENT_INT_MAGIC |
protected byte[] |
messageType |
protected byte[] |
myKi |
protected int |
mySeqNum |
protected byte[] |
peerKi |
protected int |
peerSeqNum |
protected byte[] |
sequenceNum |
private static java.lang.String |
SVR_INT_MAGIC |
| Constructor and Description |
|---|
DigestIntegrity(boolean clientMode)
Initializes DigestIntegrity implementation of SecurityCtx to
enable DIGEST-MD5 integrity checking.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
generateIntegrityKeyPair(boolean clientMode)
Generate client-server, server-client key pairs for DIGEST-MD5
integrity checking.
|
protected byte[] |
getHMAC(byte[] Ki,
byte[] seqnum,
byte[] msg,
int start,
int len)
Generates MAC to be appended onto out-going messages.
|
protected void |
incrementSeqNum()
Increment own sequence number and set answer in NBO sequenceNum field.
|
byte[] |
unwrap(byte[] incoming,
int start,
int len)
Return verified message without MAC - only if the received MAC
and re-generated MAC are the same.
|
byte[] |
wrap(byte[] outgoing,
int start,
int len)
Append MAC onto outgoing message.
|
private static final java.lang.String CLIENT_INT_MAGIC
private static final java.lang.String SVR_INT_MAGIC
protected byte[] myKi
protected byte[] peerKi
protected int mySeqNum
protected int peerSeqNum
protected final byte[] messageType
protected final byte[] sequenceNum
DigestIntegrity(boolean clientMode)
throws javax.security.sasl.SaslException
javax.security.sasl.SaslException - if an error is encountered generating the
key-pairs for integrity checking.private void generateIntegrityKeyPair(boolean clientMode)
throws java.io.IOException,
java.security.NoSuchAlgorithmException
java.io.UnsupportedEncodingException - if the UTF-8 encoding is not
supported on the platform.java.io.IOException - if an error occurs when writing to or from the
byte array output buffers.java.security.NoSuchAlgorithmException - if the MD5 message digest algorithm
cannot loaded.public byte[] wrap(byte[] outgoing,
int start,
int len)
throws javax.security.sasl.SaslException
wrap in interface SecurityCtxoutgoing - A non-null byte array containing the outgoing message.start - The offset from which to read the byte array.len - The non-zero number of bytes for be read from the offset.javax.security.sasl.SaslException - if an error is encountered converting a string
into a UTF-8 byte encoding, or if the MD5 message digest algorithm
cannot be found or if there is an error writing to the byte array
output buffers.public byte[] unwrap(byte[] incoming,
int start,
int len)
throws javax.security.sasl.SaslException
unwrap in interface SecurityCtxincoming - A non-null byte array containing the incoming
message.start - The offset from which to read the byte array.len - The non-zero number of bytes to read from the offset
position.javax.security.sasl.SaslException - if an error is encountered converting a string
into a UTF-8 byte encoding, or if the MD5 message digest algorithm
cannot be found or if there is an error writing to the byte array
output buffersprotected byte[] getHMAC(byte[] Ki,
byte[] seqnum,
byte[] msg,
int start,
int len)
throws javax.security.sasl.SaslException
Ki - A non-null byte array containing the key for the digestseqnum - A non-null byte array contain the sequence numbermsg - The message to be digestedstart - The offset from which to read the msg byte arraylen - The non-zero number of bytes to be read from the offsetjavax.security.sasl.SaslException - if an error occurs when generating MAC.protected void incrementSeqNum()