java.lang.Object
org.minidns.record.Data
org.minidns.record.DNSKEY
DNS DNSKEY record payload for DNSSEC public keys.
Contains a DNSSEC public key used to verify DNSSEC signatures for a DNS zone.
Contains a DNSSEC public key used to verify DNSSEC signatures for a DNS zone.
Field Summary
Modifier and TypeFieldDescriptionThe public key's cryptographic algorithm used.final byteThe byte value of the public key's cryptographic algorithm used.static final shortWhether the record holds a revoked key.static final shortWhether the key should be used as a secure entry point key.static final shortWhether the record holds a DNS zone key.final shortprivate final byte[]The public key material.private StringCache of the key in Base 64.private BigIntegerCache of the key as a number.private IntegerThis DNSKEY's key tag.final byteMust bePROTOCOL_RFC4034.static final byteUse the protocol defined in RFC 4034.Constructor Summary
ModifierConstructorDescriptionDNSKEY(short flags, byte protocol, byte algorithm, byte[] key) Create a record from the raw algorithm number rather than a SignatureAlgorithm.DNSKEY(short flags, byte protocol, DnssecConstants.SignatureAlgorithm algorithm, byte[] key) Create a record from a SignatureAlgorithm.privateDNSKEY(short flags, byte protocol, DnssecConstants.SignatureAlgorithm algorithm, byte algorithmByte, byte[] key) Creates a record from its parts.Method Summary
Modifier and TypeMethodDescriptionbyte[]getKey()Copy of the public key material.Wrap the public key material in a stream.Base64 encoding of the public key material, cached after the first call.The public key material as a big-endian integer, cached after the first call.intLength of the public key material.intRetrieve the key tag identifying this DNSKEY.getType()Record type of this record.booleanWhether the secure entry point flag is set.booleankeyEquals(byte[] otherKey) Compare this record's key material against another key.static DNSKEYparse(DataInputStream dis, int length) Parse a DNSKEY record from the wire format.voidWrite the flags, protocol, algorithm number and key to the stream.toString()Diagnostic form of the record.Methods inherited from class Data
equals, hashCode, length, toByteArray, toOutputStream, toOutputStreamModifier and TypeMethodDescriptionfinal booleanfinal inthashCode()final intlength()Serialize this record, if that has not been done already, and report the resulting wire size.final byte[]Serialize this record, if that has not been done already, and return a copy of the result so callers cannot mutate the cached bytes.final voidWrite the binary representation of this payload to the givenDataOutputStream.final voidtoOutputStream(OutputStream outputStream) Write the binary representation to the given OutputStream.
Field Details
FLAG_SECURE_ENTRY_POINT
public static final short FLAG_SECURE_ENTRY_POINTWhether the key should be used as a secure entry point key. see RFC 3757- See Also:
FLAG_REVOKE
public static final short FLAG_REVOKEWhether the record holds a revoked key.- See Also:
FLAG_ZONE
public static final short FLAG_ZONEWhether the record holds a DNS zone key.- See Also:
PROTOCOL_RFC4034
public static final byte PROTOCOL_RFC4034Use the protocol defined in RFC 4034.- See Also:
flags
public final short flags- See Also:
protocol
public final byte protocolMust bePROTOCOL_RFC4034.algorithm
The public key's cryptographic algorithm used.algorithmByte
public final byte algorithmByteThe byte value of the public key's cryptographic algorithm used.key
private final byte[] keyThe public key material. The format depends on the algorithm of the key being stored.keyTag
This DNSKEY's key tag. Calculated just-in-time when usinggetKeyTag()keyBase64Cache
Cache of the key in Base 64.keyBigIntegerCache
Cache of the key as a number.
Constructor Details
DNSKEY
private DNSKEY(short flags, byte protocol, DnssecConstants.SignatureAlgorithm algorithm, byte algorithmByte, byte[] key) Creates a record from its parts.- Parameters:
flags- the flags of the keyprotocol- the protocol of the key, always dnssecalgorithm- the signature algorithmalgorithmByte- the wire value of the algorithmkey- the key material
DNSKEY
public DNSKEY(short flags, byte protocol, byte algorithm, byte[] key) Create a record from the raw algorithm number rather than a SignatureAlgorithm.- Parameters:
flags- the DNSKEY flags bitmapprotocol- must bePROTOCOL_RFC4034algorithm- the algorithm number as it appears on the wirekey- the public key material, formatted per the algorithm
DNSKEY
Create a record from a SignatureAlgorithm.- Parameters:
flags- the DNSKEY flags bitmapprotocol- must bePROTOCOL_RFC4034algorithm- the public key's cryptographic algorithmkey- the public key material, formatted per the algorithm
Method Details
parse
Parse a DNSKEY record from the wire format.- Parameters:
dis- the stream positioned at the start of the record payloadlength- the size of the record in bytes, including the 4 byte flags, protocol and algorithm preamble- Returns:
- the parsed record
- Throws:
IOException- if length is under 4, or the stream ends before the key material is complete
getType
Record type of this record.- Specified by:
getTypein classData- Returns:
Record.TYPE.DNSKEY
getKeyTag
public int getKeyTag()Retrieve the key tag identifying this DNSKEY. The key tag is used within the DS and RRSIG record to distinguish multiple keys for the same name. This implementation is based on the reference implementation shown in RFC 4034 Appendix B.- Returns:
- this DNSKEY's key tag
serialize
Write the flags, protocol, algorithm number and key to the stream.- Specified by:
serializein classData- Parameters:
dos- the stream to write the wire format to- Throws:
IOException- if the stream rejects the write
toString
getKeyLength
public int getKeyLength()Length of the public key material.- Returns:
- the number of bytes in the public key
getKey
public byte[] getKey()Copy of the public key material.- Returns:
- a copy of the key bytes, so callers cannot alter this record
getKeyAsDataInputStream
Wrap the public key material in a stream.- Returns:
- a stream reading over the key bytes
getKeyBase64
Base64 encoding of the public key material, cached after the first call.- Returns:
- the key encoded as base64
getKeyBigInteger
The public key material as a big-endian integer, cached after the first call.- Returns:
- the key as a BigInteger
keyEquals
public boolean keyEquals(byte[] otherKey) Compare this record's key material against another key.- Parameters:
otherKey- the key bytes to compare against- Returns:
- true if both keys are byte for byte identical
isSecureEntryPoint
public boolean isSecureEntryPoint()Whether the secure entry point flag is set.- Returns:
- true if this is a secure entry point key