| 1 |
/* |
| 2 |
* Copyright 2015-2020 the original author or authors |
| 3 |
* |
| 4 |
* This software is licensed under the Apache License, Version 2.0, |
| 5 |
* the GNU Lesser General Public License version 2 or later ("LGPL") |
| 6 |
* and the WTFPL. |
| 7 |
* You may choose either license to govern your use of this software only |
| 8 |
* upon the condition that you accept all of the terms of either |
| 9 |
* the Apache License 2.0, the LGPL 2.1+ or the WTFPL. |
| 10 |
*/ |
| 11 |
package org.minidns.constants; |
| 12 |
|
| 13 |
import java.util.HashMap; |
| 14 |
import java.util.Map; |
| 15 |
|
| 16 |
public final class DnssecConstants { |
| 17 |
/** |
| 18 |
* Do not allow to instantiate DNSSECConstants |
| 19 |
*/ |
| 20 |
private DnssecConstants() { |
| 21 |
} |
| 22 |
|
| 23 |
private static final Map<Byte, SignatureAlgorithm> SIGNATURE_ALGORITHM_LUT = new HashMap<>(); |
| 24 |
|
| 25 |
/** |
| 26 |
* DNSSEC Signature Algorithms. |
| 27 |
* |
| 28 |
* @see <a href= |
| 29 |
* "http://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml"> |
| 30 |
* IANA DNSSEC Algorithm Numbers</a> |
| 31 |
*/ |
| 32 |
public enum SignatureAlgorithm { |
| 33 |
@Deprecated |
| 34 |
RSAMD5(1, "RSA/MD5"), |
| 35 |
DH(2, "Diffie-Hellman"), |
| 36 |
DSA(3, "DSA/SHA1"), |
| 37 |
RSASHA1(5, "RSA/SHA-1"), |
| 38 |
DSA_NSEC3_SHA1(6, "DSA_NSEC3-SHA1"), |
| 39 |
RSASHA1_NSEC3_SHA1(7, "RSASHA1-NSEC3-SHA1"), |
| 40 |
RSASHA256(8, "RSA/SHA-256"), |
| 41 |
RSASHA512(10, "RSA/SHA-512"), |
| 42 |
ECC_GOST(12, "GOST R 34.10-2001"), |
| 43 |
ECDSAP256SHA256(13, "ECDSA Curve P-256 with SHA-256"), |
| 44 |
ECDSAP384SHA384(14, "ECDSA Curve P-384 with SHA-384"), |
| 45 |
INDIRECT(252, "Reserved for Indirect Keys"), |
| 46 |
PRIVATEDNS(253, "private algorithm"), |
| 47 |
PRIVATEOID(254, "private algorithm oid"), |
| 48 |
; |
| 49 |
|
| 50 |
SignatureAlgorithm(int number, String description) { |
| 51 |
if (number < 0 || number > 255) { |
| 52 |
throw new IllegalArgumentException(); |
| 53 |
} |
| 54 |
this.number = (byte) number; |
| 55 |
this.description = description; |
| 56 |
SIGNATURE_ALGORITHM_LUT.put(this.number, this); |
| 57 |
} |
| 58 |
|
| 59 |
public final byte number; |
| 60 |
public final String description; |
| 61 |
|
| 62 |
public static SignatureAlgorithm forByte(byte b) { |
| 63 |
return SIGNATURE_ALGORITHM_LUT.get(b); |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
private static final Map<Byte, DigestAlgorithm> DELEGATION_DIGEST_LUT = new HashMap<>(); |
| 68 |
|
| 69 |
/** |
| 70 |
* DNSSEC Digest Algorithms. |
| 71 |
* |
| 72 |
* @see <a href= |
| 73 |
* "https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml"> |
| 74 |
* IANA Delegation Signer (DS) Resource Record (RR)</a> |
| 75 |
*/ |
| 76 |
public enum DigestAlgorithm { |
| 77 |
SHA1(1, "SHA-1"), |
| 78 |
SHA256(2, "SHA-256"), |
| 79 |
GOST(3, "GOST R 34.11-94"), |
| 80 |
SHA384(4, "SHA-384"), |
| 81 |
; |
| 82 |
|
| 83 |
DigestAlgorithm(int value, String description) { |
| 84 |
if (value < 0 || value > 255) { |
| 85 |
throw new IllegalArgumentException(); |
| 86 |
} |
| 87 |
this.value = (byte) value; |
| 88 |
this.description = description; |
| 89 |
DELEGATION_DIGEST_LUT.put(this.value, this); |
| 90 |
} |
| 91 |
|
| 92 |
public final byte value; |
| 93 |
public final String description; |
| 94 |
|
| 95 |
public static DigestAlgorithm forByte(byte b) { |
| 96 |
return DELEGATION_DIGEST_LUT.get(b); |
| 97 |
} |
| 98 |
} |
| 99 |
} |