Package org.xbill.DNS
Class DNSSEC
java.lang.Object
org.xbill.DNS.DNSSEC
Constants and methods relating to DNSSEC.
DNSSEC provides authentication for DNS information.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDomain Name System Security (DNSSEC) Algorithm Numbers.static classDNSSEC Delegation Signer (DS) Resource Record (RR) Type Digest Algorithms.static classA DNSSEC exception.private static classstatic classThe key data provided is inconsistent.static classTheDNSKEYRecordused for the validation is not a zone signing key.static classA DNSSEC verification failed because fields in the DNSKEY and RRSIG records do not match.static classThe cryptographic data in a DNSSEC key is malformed.static classNo signature was found.static classA DNSSEC verification failed because the signature has expired.static classA DNSSEC verification failed because the signature has not yet become valid.static classA DNSSEC verification failed because the cryptographic signature verification failed.static classAn algorithm is unsupported by this DNSSEC implementation. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int(package private) static final int(package private) static final int(package private) static final intprivate static final intprivate static final DNSSEC.ECKeyInfoprivate static final DNSSEC.ECKeyInfoprivate static final DNSSEC.ECKeyInfo -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringalgString(int alg) Convert an algorithm number to the corresponding JCA string.private static IOExceptionasn1ParseException(Object expected, Object actual) private static int(package private) static voidcheckAlgorithm(PrivateKey key, int alg) private static voidcheckKeyAndSigRecord(SIGBase sig, KEYBase key, Instant date) static byte[]digestMessage(SIGRecord sig, Message msg, byte[] previous) Creates a byte array containing the concatenation of the fields of the SIG(0) record and the message to be signed.static byte[]digestRRset(RRSIGRecord rrsig, RRset rrset) Creates a byte array containing the concatenation of the fields of the SIG record and the RRsets to be signed/verified.private static voidprivate static byte[]dsaSignatureFromDNS(byte[] signature, int keyLength, boolean skipT) private static byte[]dsaSignatureToDNS(byte[] signature, int rsLen, int t) private static byte[]private static byte[]fromECDSAPublicKey(ECPublicKey key, DNSSEC.ECKeyInfo keyinfo) private static byte[]fromECGOSTPublicKey(ECPublicKey key, DNSSEC.ECKeyInfo keyinfo) private static byte[](package private) static byte[]fromPublicKey(PublicKey key, int alg) Builds a DNSKEY record from a PublicKeyprivate static byte[](package private) static byte[]generateDSDigest(DNSKEYRecord key, int digestid) Generate the digest value for a DS keyprivate static intgetDsaIntLen(byte[] bigint, int dsaLen) private static booleanprivate static BigIntegerprivate static BigIntegerreadBigInteger(DNSInput in, int len) private static BigIntegerreadBigIntegerLittleEndian(DNSInput in, int len) private static voidreverseByteArray(byte[] array) (package private) static byte[]sign(PrivateKey privkey, PublicKey pubkey, int alg, byte[] data, String provider) static RRSIGRecordsign(RRset rrset, DNSKEYRecord key, PrivateKey privkey, Instant inception, Instant expiration) Generate a DNSSEC signature.static RRSIGRecordsign(RRset rrset, DNSKEYRecord key, PrivateKey privkey, Instant inception, Instant expiration, String provider) Generate a DNSSEC signature.static RRSIGRecordsign(RRset rrset, DNSKEYRecord key, PrivateKey privkey, Date inception, Date expiration) Deprecated.static RRSIGRecordsign(RRset rrset, DNSKEYRecord key, PrivateKey privkey, Date inception, Date expiration, String provider) Deprecated.(package private) static SIGRecordsignMessage(Message message, SIGRecord previous, KEYRecord key, PrivateKey privkey, Instant inception, Instant expiration) private static PublicKeytoDSAPublicKey(byte[] key) private static PublicKeytoECDSAPublicKey(byte[] key, DNSSEC.ECKeyInfo keyinfo) private static PublicKeytoECGOSTPublicKey(byte[] key, DNSSEC.ECKeyInfo keyinfo) private static PublicKeytoEdDSAPublicKey(byte[] key, byte algId) (package private) static PublicKeytoPublicKey(int alg, byte[] key, Record r) Converts a KEY/DNSKEY record into a PublicKey(package private) static PublicKeyConverts a KEY/DNSKEY record into a PublicKeyprivate static PublicKeytoRSAPublicKey(byte[] key) private static voidtransformAns1IntToDns(int rsLen, DNSInput in, DNSOutput out) private static byte[]trimByteArray(byte[] array) private static voidstatic voidverify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key) Verify a DNSSEC signature.static voidverify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key, Instant date) Verify a DNSSEC signature.static voidverify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key, Date date) Deprecated.(package private) static voidverifyMessage(Message message, byte[] bytes, SIGRecord sig, SIGRecord previous, KEYRecord key, Instant now) private static voidwriteAsn1Int(int keyLength, DNSOutput out, byte[] bigint, int bigintLen) private static voidwriteBigInteger(DNSOutput out, BigInteger val) private static voidwritePaddedBigInteger(DNSOutput out, BigInteger val, int len) private static voidwritePaddedBigIntegerLittleEndian(DNSOutput out, BigInteger val, int len)
-
Field Details
-
GOST
-
ECDSA_P256
-
ECDSA_P384
-
ASN1_SEQ
static final int ASN1_SEQ- See Also:
-
ASN1_INT
static final int ASN1_INT- See Also:
-
ASN1_BITSTRING
static final int ASN1_BITSTRING- See Also:
-
ASN1_OID
static final int ASN1_OID- See Also:
-
DSA_LEN
private static final int DSA_LEN- See Also:
-
-
Constructor Details
-
DNSSEC
private DNSSEC()
-
-
Method Details
-
digestSIG
-
digestRRset
Creates a byte array containing the concatenation of the fields of the SIG record and the RRsets to be signed/verified. This does not perform a cryptographic digest.- Parameters:
rrsig- The RRSIG record used to sign/verify the rrset.rrset- The data to be signed/verified.- Returns:
- The data to be cryptographically signed or verified.
-
digestMessage
Creates a byte array containing the concatenation of the fields of the SIG(0) record and the message to be signed. This does not perform a cryptographic digest.- Parameters:
sig- The SIG record used to sign the rrset.msg- The message to be signed.previous- If this is a response, the signature from the query.- Returns:
- The data to be cryptographically signed.
-
bigIntegerLength
-
readBigInteger
- Throws:
IOException
-
readBigInteger
-
trimByteArray
private static byte[] trimByteArray(byte[] array) -
reverseByteArray
private static void reverseByteArray(byte[] array) -
readBigIntegerLittleEndian
- Throws:
IOException
-
writeBigInteger
-
writePaddedBigInteger
-
writePaddedBigIntegerLittleEndian
-
toRSAPublicKey
- Throws:
IOExceptionGeneralSecurityException
-
toDSAPublicKey
private static PublicKey toDSAPublicKey(byte[] key) throws IOException, GeneralSecurityException, DNSSEC.MalformedKeyException -
toECGOSTPublicKey
private static PublicKey toECGOSTPublicKey(byte[] key, DNSSEC.ECKeyInfo keyinfo) throws IOException, GeneralSecurityException - Throws:
IOExceptionGeneralSecurityException
-
toECDSAPublicKey
private static PublicKey toECDSAPublicKey(byte[] key, DNSSEC.ECKeyInfo keyinfo) throws IOException, GeneralSecurityException - Throws:
IOExceptionGeneralSecurityException
-
toEdDSAPublicKey
- Throws:
GeneralSecurityException
-
toPublicKey
Converts a KEY/DNSKEY record into a PublicKey- Throws:
DNSSEC.DNSSECException
-
toPublicKey
Converts a KEY/DNSKEY record into a PublicKey- Throws:
DNSSEC.DNSSECException
-
fromRSAPublicKey
-
fromDSAPublicKey
-
fromECGOSTPublicKey
-
fromECDSAPublicKey
-
fromEdDSAPublicKey
-
fromPublicKey
Builds a DNSKEY record from a PublicKey- Throws:
DNSSEC.DNSSECException
-
algString
Convert an algorithm number to the corresponding JCA string.- Parameters:
alg- The algorithm number.- Throws:
DNSSEC.UnsupportedAlgorithmException- The algorithm is unknown.
-
asn1ParseException
-
dsaSignatureFromDNS
private static byte[] dsaSignatureFromDNS(byte[] signature, int keyLength, boolean skipT) throws DNSSEC.DNSSECException, IOException - Throws:
DNSSEC.DNSSECExceptionIOException
-
getDsaIntLen
private static int getDsaIntLen(byte[] bigint, int dsaLen) -
writeAsn1Int
-
dsaSignatureToDNS
- Throws:
IOException
-
transformAns1IntToDns
- Throws:
IOException
-
verify
private static void verify(KEYBase keyRecord, SIGBase sigRecord, byte[] data, int coveredType) throws DNSSEC.DNSSECException - Throws:
DNSSEC.DNSSECException
-
matches
-
verify
public static void verify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key) throws DNSSEC.DNSSECException Verify a DNSSEC signature.- Parameters:
rrset- The data to be verified.rrsig- The RRSIG record containing the signature.key- The DNSKEY record to verify the signature with.- Throws:
DNSSEC.UnsupportedAlgorithmException- The algorithm is unknownDNSSEC.MalformedKeyException- The key is malformedDNSSEC.KeyMismatchException- The key and signature do not matchDNSSEC.SignatureExpiredException- The signature has expiredDNSSEC.SignatureNotYetValidException- The signature is not yet validDNSSEC.SignatureVerificationException- The signature does not verify.DNSSEC.DNSSECException- Some other error occurred.
-
verify
@Deprecated public static void verify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key, Date date) throws DNSSEC.DNSSECException Deprecated.Verify a DNSSEC signature.- Parameters:
rrset- The data to be verified.rrsig- The RRSIG record containing the signature.key- The DNSKEY record to verify the signature with.date- The date against which the signature is verified.- Throws:
DNSSEC.UnsupportedAlgorithmException- The algorithm is unknownDNSSEC.MalformedKeyException- The key is malformedDNSSEC.KeyMismatchException- The key and signature do not matchDNSSEC.SignatureExpiredException- The signature has expiredDNSSEC.SignatureNotYetValidException- The signature is not yet validDNSSEC.SignatureVerificationException- The signature does not verify.DNSSEC.DNSSECException- Some other error occurred.
-
verify
public static void verify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key, Instant date) throws DNSSEC.DNSSECException Verify a DNSSEC signature.- Parameters:
rrset- The data to be verified.rrsig- The RRSIG record containing the signature.key- The DNSKEY record to verify the signature with.date- The date against which the signature is verified.- Throws:
DNSSEC.UnsupportedAlgorithmException- The algorithm is unknownDNSSEC.MalformedKeyException- The key is malformedDNSSEC.KeyMismatchException- The key and signature do not matchDNSSEC.SignatureExpiredException- The signature has expiredDNSSEC.SignatureNotYetValidException- The signature is not yet validDNSSEC.SignatureVerificationException- The signature does not verify.DNSSEC.DNSSECException- Some other error occurred.
-
checkKeyAndSigRecord
private static void checkKeyAndSigRecord(SIGBase sig, KEYBase key, Instant date) throws DNSSEC.DNSSECException - Throws:
DNSSEC.DNSSECException
-
sign
static byte[] sign(PrivateKey privkey, PublicKey pubkey, int alg, byte[] data, String provider) throws DNSSEC.DNSSECException - Throws:
DNSSEC.DNSSECException
-
checkAlgorithm
-
sign
@Deprecated public static RRSIGRecord sign(RRset rrset, DNSKEYRecord key, PrivateKey privkey, Date inception, Date expiration) throws DNSSEC.DNSSECException Deprecated.Generate a DNSSEC signature. key and privateKey must refer to the same underlying cryptographic key.- Parameters:
rrset- The data to be signedkey- The DNSKEY record to use as part of signingprivkey- The PrivateKey to use when signinginception- The time at which the signatures should become validexpiration- The time at which the signatures should expire- Returns:
- The generated signature
- Throws:
DNSSEC.UnsupportedAlgorithmException- The algorithm is unknownDNSSEC.MalformedKeyException- The key is malformedDNSSEC.DNSSECException- Some other error occurred.
-
sign
@Deprecated public static RRSIGRecord sign(RRset rrset, DNSKEYRecord key, PrivateKey privkey, Date inception, Date expiration, String provider) throws DNSSEC.DNSSECException Deprecated.Generate a DNSSEC signature. key and privateKey must refer to the same underlying cryptographic key.- Parameters:
rrset- The data to be signedkey- The DNSKEY record to use as part of signingprivkey- The PrivateKey to use when signinginception- The time at which the signatures should become validexpiration- The time at which the signatures should expire- Returns:
- The generated signature
- Throws:
DNSSEC.UnsupportedAlgorithmException- The algorithm is unknownDNSSEC.MalformedKeyException- The key is malformedDNSSEC.DNSSECException- Some other error occurred.
-
sign
public static RRSIGRecord sign(RRset rrset, DNSKEYRecord key, PrivateKey privkey, Instant inception, Instant expiration) throws DNSSEC.DNSSECException Generate a DNSSEC signature. key and privateKey must refer to the same underlying cryptographic key.- Parameters:
rrset- The data to be signedkey- The DNSKEY record to use as part of signingprivkey- The PrivateKey to use when signinginception- The time at which the signatures should become validexpiration- The time at which the signatures should expire- Returns:
- The generated signature
- Throws:
DNSSEC.UnsupportedAlgorithmException- The algorithm is unknownDNSSEC.MalformedKeyException- The key is malformedDNSSEC.DNSSECException- Some other error occurred.
-
sign
public static RRSIGRecord sign(RRset rrset, DNSKEYRecord key, PrivateKey privkey, Instant inception, Instant expiration, String provider) throws DNSSEC.DNSSECException Generate a DNSSEC signature. key and privateKey must refer to the same underlying cryptographic key.- Parameters:
rrset- The data to be signedkey- The DNSKEY record to use as part of signingprivkey- The PrivateKey to use when signinginception- The time at which the signatures should become validexpiration- The time at which the signatures should expireprovider- The name of the JCA provider. If non-null, it will be passed to JCA getInstance() methods.- Returns:
- The generated signature
- Throws:
DNSSEC.UnsupportedAlgorithmException- The algorithm is unknownDNSSEC.MalformedKeyException- The key is malformedDNSSEC.DNSSECException- Some other error occurred.
-
signMessage
static SIGRecord signMessage(Message message, SIGRecord previous, KEYRecord key, PrivateKey privkey, Instant inception, Instant expiration) throws DNSSEC.DNSSECException - Throws:
DNSSEC.DNSSECException
-
verifyMessage
static void verifyMessage(Message message, byte[] bytes, SIGRecord sig, SIGRecord previous, KEYRecord key, Instant now) throws DNSSEC.DNSSECException - Throws:
DNSSEC.DNSSECException
-
generateDSDigest
Generate the digest value for a DS key- Parameters:
key- Which is covered by the DS recorddigestid- The type of digest- Returns:
- The digest value as an array of bytes
-
sign(RRset, DNSKEYRecord, PrivateKey, Instant, Instant)