| 1 |
package dnsstring |
| 2 |
|
| 3 |
// Wire constants and supported types. |
| 4 |
const ( |
| 5 |
|
| 6 |
// If you add one here, also add internal/dnsstrings/types.go |
| 7 |
|
| 8 |
TypeNone uint16 = 0 |
| 9 |
TypeA uint16 = 1 |
| 10 |
TypeNS uint16 = 2 |
| 11 |
TypeMD uint16 = 3 |
| 12 |
TypeMF uint16 = 4 |
| 13 |
TypeCNAME uint16 = 5 |
| 14 |
TypeSOA uint16 = 6 |
| 15 |
TypeMB uint16 = 7 |
| 16 |
TypeMG uint16 = 8 |
| 17 |
TypeMR uint16 = 9 |
| 18 |
TypeNULL uint16 = 10 |
| 19 |
TypePTR uint16 = 12 |
| 20 |
TypeHINFO uint16 = 13 |
| 21 |
TypeMINFO uint16 = 14 |
| 22 |
TypeMX uint16 = 15 |
| 23 |
TypeTXT uint16 = 16 |
| 24 |
TypeRP uint16 = 17 |
| 25 |
TypeAFSDB uint16 = 18 |
| 26 |
TypeX25 uint16 = 19 |
| 27 |
TypeISDN uint16 = 20 |
| 28 |
TypeRT uint16 = 21 |
| 29 |
TypeNSAPPTR uint16 = 23 |
| 30 |
TypeSIG uint16 = 24 |
| 31 |
TypeKEY uint16 = 25 |
| 32 |
TypePX uint16 = 26 |
| 33 |
TypeGPOS uint16 = 27 |
| 34 |
TypeAAAA uint16 = 28 |
| 35 |
TypeLOC uint16 = 29 |
| 36 |
TypeNXT uint16 = 30 |
| 37 |
TypeEID uint16 = 31 |
| 38 |
TypeNIMLOC uint16 = 32 |
| 39 |
TypeSRV uint16 = 33 |
| 40 |
TypeATMA uint16 = 34 |
| 41 |
TypeNAPTR uint16 = 35 |
| 42 |
TypeKX uint16 = 36 |
| 43 |
TypeCERT uint16 = 37 |
| 44 |
TypeDNAME uint16 = 39 |
| 45 |
TypeOPT uint16 = 41 |
| 46 |
TypeAPL uint16 = 42 // Not implemented. |
| 47 |
TypeDS uint16 = 43 |
| 48 |
TypeSSHFP uint16 = 44 |
| 49 |
TypeIPSECKEY uint16 = 45 // Not implemented. |
| 50 |
TypeRRSIG uint16 = 46 |
| 51 |
TypeNSEC uint16 = 47 |
| 52 |
TypeDNSKEY uint16 = 48 |
| 53 |
TypeDHCID uint16 = 49 |
| 54 |
TypeNSEC3 uint16 = 50 |
| 55 |
TypeNSEC3PARAM uint16 = 51 |
| 56 |
TypeTLSA uint16 = 52 |
| 57 |
TypeSMIMEA uint16 = 53 |
| 58 |
TypeHIP uint16 = 55 |
| 59 |
TypeNINFO uint16 = 56 |
| 60 |
TypeRKEY uint16 = 57 |
| 61 |
TypeTALINK uint16 = 58 |
| 62 |
TypeCDS uint16 = 59 |
| 63 |
TypeCDNSKEY uint16 = 60 |
| 64 |
TypeOPENPGPKEY uint16 = 61 |
| 65 |
TypeCSYNC uint16 = 62 |
| 66 |
TypeZONEMD uint16 = 63 |
| 67 |
TypeSVCB uint16 = 64 |
| 68 |
TypeHTTPS uint16 = 65 |
| 69 |
TypeDSYNC uint16 = 66 |
| 70 |
TypeUNECE uint16 = 69 // Not implemented, see https://www.ietf.org/archive/id/draft-woodcock-faltstrom-external-registry-rrtypes-01.html. |
| 71 |
TypeISO uint16 = 70 // Not implemented, see https://www.ietf.org/archive/id/draft-woodcock-faltstrom-external-registry-rrtypes-01.html. |
| 72 |
TypeSPF uint16 = 99 |
| 73 |
TypeUINFO uint16 = 100 |
| 74 |
TypeUID uint16 = 101 |
| 75 |
TypeGID uint16 = 102 |
| 76 |
TypeUNSPEC uint16 = 103 |
| 77 |
TypeNID uint16 = 104 |
| 78 |
TypeL32 uint16 = 105 |
| 79 |
TypeL64 uint16 = 106 |
| 80 |
TypeLP uint16 = 107 |
| 81 |
TypeEUI48 uint16 = 108 |
| 82 |
TypeEUI64 uint16 = 109 |
| 83 |
TypeNXNAME uint16 = 128 |
| 84 |
TypeURI uint16 = 256 |
| 85 |
TypeCAA uint16 = 257 |
| 86 |
TypeAVC uint16 = 258 |
| 87 |
TypeAMTRELAY uint16 = 260 // Not implemented. |
| 88 |
TypeRESINFO uint16 = 261 |
| 89 |
TypeWALLET uint16 = 262 |
| 90 |
TypeCLA uint16 = 263 |
| 91 |
TypeIPN uint16 = 264 |
| 92 |
|
| 93 |
TypeTKEY uint16 = 249 |
| 94 |
TypeTSIG uint16 = 250 |
| 95 |
|
| 96 |
// Valid question types only. |
| 97 |
TypeIXFR uint16 = 251 |
| 98 |
TypeAXFR uint16 = 252 |
| 99 |
TypeMAILB uint16 = 253 |
| 100 |
TypeMAILA uint16 = 254 |
| 101 |
TypeANY uint16 = 255 |
| 102 |
|
| 103 |
TypeTA uint16 = 32768 |
| 104 |
TypeDLV uint16 = 32769 |
| 105 |
TypeDELEG uint16 = 65432 // Provisional type code. |
| 106 |
TypeDELEGPARAM uint16 = 65433 // Provisional type code. |
| 107 |
TypeReserved uint16 = 65535 |
| 108 |
) |
| 109 |
|
| 110 |
// Various constants used in the LOC RR. See RFC 1876. |
| 111 |
const ( |
| 112 |
LOCEquator = 1 << 31 // RFC 1876, Section 2. |
| 113 |
LOCPrimemeridian = 1 << 31 // RFC 1876, Section 2. |
| 114 |
LOCHours = 60 * 1000 |
| 115 |
LOCDegrees = 60 * LOCHours |
| 116 |
LOCAltitudebase = 100000 |
| 117 |
) |
| 118 |
|
| 119 |
// DNSSEC encryption algorithm codes. |
| 120 |
const ( |
| 121 |
_ uint8 = iota |
| 122 |
RSAMD5 |
| 123 |
DH |
| 124 |
DSA |
| 125 |
_ // Skip 4, RFC 6725, section 2.1. |
| 126 |
RSASHA1 |
| 127 |
DSANSEC3SHA1 |
| 128 |
RSASHA1NSEC3SHA1 |
| 129 |
RSASHA256 |
| 130 |
_ // Skip 9, RFC 6725, section 2.1. |
| 131 |
RSASHA512 |
| 132 |
_ // Skip 11, RFC 6725, section 2.1. |
| 133 |
ECCGOST |
| 134 |
ECDSAP256SHA256 |
| 135 |
ECDSAP384SHA384 |
| 136 |
ED25519 |
| 137 |
ED448 |
| 138 |
SM2SM3 // See RFC 9563. |
| 139 |
MLDSA44 // See draft-westerbaan-dnssec-mldsa. |
| 140 |
ECCGOST12 uint8 = 23 // See RFC 9558. |
| 141 |
INDIRECT uint8 = 252 |
| 142 |
PRIVATEDNS uint8 = 253 // Private (experimental keys) |
| 143 |
PRIVATEOID uint8 = 254 |
| 144 |
) |
| 145 |
|
| 146 |
// AlgorithmToString is a map of algorithm IDs to algorithm names. |
| 147 |
var AlgorithmToString = map[uint8]string{ |
| 148 |
RSAMD5: "RSAMD5", |
| 149 |
DH: "DH", |
| 150 |
DSA: "DSA", |
| 151 |
RSASHA1: "RSASHA1", |
| 152 |
DSANSEC3SHA1: "DSA-NSEC3-SHA1", |
| 153 |
RSASHA1NSEC3SHA1: "RSASHA1-NSEC3-SHA1", |
| 154 |
RSASHA256: "RSASHA256", |
| 155 |
RSASHA512: "RSASHA512", |
| 156 |
ECCGOST: "ECC-GOST", |
| 157 |
ECDSAP256SHA256: "ECDSAP256SHA256", |
| 158 |
ECDSAP384SHA384: "ECDSAP384SHA384", |
| 159 |
ED25519: "ED25519", |
| 160 |
ED448: "ED448", |
| 161 |
SM2SM3: "SM2SM3", |
| 162 |
MLDSA44: "MLDSA44", |
| 163 |
ECCGOST12: "ECC-GOST12", |
| 164 |
INDIRECT: "INDIRECT", |
| 165 |
PRIVATEDNS: "PRIVATEDNS", |
| 166 |
PRIVATEOID: "PRIVATEOID", |
| 167 |
} |
| 168 |
|
| 169 |
// Different Certificate Types, see RFC 4398, Section 2.1. |
| 170 |
const ( |
| 171 |
CertPKIX = 1 + iota |
| 172 |
CertSPKI |
| 173 |
CertPGP |
| 174 |
CertIPIX |
| 175 |
CertISPKI |
| 176 |
CertIPGP |
| 177 |
CertACPKIX |
| 178 |
CertIACPKIX |
| 179 |
CertURI = 253 |
| 180 |
CertOID = 254 |
| 181 |
) |
| 182 |
|
| 183 |
// CertTypeToString converts the Cert Type to its string representation. |
| 184 |
// See RFC 4398 and RFC 6944. |
| 185 |
var CertTypeToString = map[uint16]string{ |
| 186 |
CertPKIX: "PKIX", |
| 187 |
CertSPKI: "SPKI", |
| 188 |
CertPGP: "PGP", |
| 189 |
CertIPIX: "IPIX", |
| 190 |
CertISPKI: "ISPKI", |
| 191 |
CertIPGP: "IPGP", |
| 192 |
CertACPKIX: "ACPKIX", |
| 193 |
CertIACPKIX: "IACPKIX", |
| 194 |
CertURI: "URI", |
| 195 |
CertOID: "OID", |
| 196 |
} |