cert-spec.txt 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. Ed25519 certificates in Tor
  2. 1. Scope and Preliminaries
  3. This document describes a certificate format that Tor uses for
  4. its Ed25519 internal certificates. It is not the only
  5. certificate format that Tor uses. For the certificates that
  6. authorities use for their signing keys, see dir-spec.txt.
  7. Additionally, Tor uses TLS, which depends on X.509 certificates;
  8. see tor-spec.txt for details.
  9. The certificates in this document were first introduced in
  10. proposal 220, and were first supported by Tor in Tor version
  11. 0.2.7.2-alpha.
  12. 1.1. Signing
  13. All signatures here, unless otherwise specified, are computed
  14. using an Ed25519 key.
  15. In order to future-proof the format, before signing anything, the
  16. signed document is prefixed with a personalization string, which
  17. will be different in each case.
  18. 1.2 Integer encoding
  19. Network byte order (big-endian) is used to encode all integer values
  20. in Ed25519 certificates unless explicitly specified otherwise.
  21. 2. Document formats
  22. 2.1. Ed25519 Certificates
  23. When generating a signing key, we also generate a certificate for it.
  24. Unlike the certificates for authorities' signing keys, these
  25. certificates need to be sent around frequently, in significant
  26. numbers. So we'll choose a compact representation.
  27. VERSION [1 Byte]
  28. CERT_TYPE [1 Byte]
  29. EXPIRATION_DATE [4 Bytes]
  30. CERT_KEY_TYPE [1 byte]
  31. CERTIFIED_KEY [32 Bytes]
  32. N_EXTENSIONS [1 byte]
  33. EXTENSIONS [N_EXTENSIONS times]
  34. SIGNATURE [64 Bytes]
  35. The "VERSION" field holds the value [01]. The "CERT_TYPE" field
  36. holds a value depending on the type of certificate. (See appendix
  37. A.1.) The CERTIFIED_KEY field is an Ed25519 public key if
  38. CERT_KEY_TYPE is [01], or a SHA256 hash of some other key type
  39. depending on the value of CERT_KEY_TYPE. The EXPIRATION_DATE is a
  40. date, given in HOURS since the epoch, after which this
  41. certificate isn't valid. (A four-byte field here will work fine
  42. until 10136 A.D.)
  43. The EXTENSIONS field contains zero or more extensions, each of
  44. the format:
  45. ExtLength [2 bytes]
  46. ExtType [1 byte]
  47. ExtFlags [1 byte]
  48. ExtData [ExtLength bytes]
  49. The meaning of the ExtData field in an extension is type-dependent.
  50. The ExtFlags field holds flags; this flag is currently defined:
  51. 1 -- AFFECTS_VALIDATION. If this flag is present, then the
  52. extension affects whether the certificate is valid; clients
  53. must not accept the certificate as valid unless they
  54. understand the extension.
  55. It is an error for an extension to be truncated; such a
  56. certificate is invalid.
  57. Before processing any certificate, parties SHOULD know which
  58. identity key it is supposed to be signed by, and then check the
  59. signature. The signature is formed by signing the first N-64
  60. bytes of the certificate.
  61. 2.2. Basic extensions
  62. 2.2.1. Signed-with-ed25519-key extension [type 04]
  63. In several places, it's desirable to bundle the key signing a
  64. certificate along with the certificate. We do so with this
  65. extension.
  66. ExtLength = 32
  67. ExtData =
  68. An ed25519 key [32 bytes]
  69. When this extension is present, it MUST match the key used to
  70. sign the certificate.
  71. 2.3. RSA->Ed25519 cross-certificate
  72. Certificate type [07] (Cross-certification of Ed25519 identity
  73. with RSA key) contains the following data:
  74. ED25519_KEY [32 bytes]
  75. EXPIRATION_DATE [4 bytes]
  76. SIGLEN [1 byte]
  77. SIGNATURE [SIGLEN bytes]
  78. Here, the Ed25519 identity key is signed with router's RSA
  79. identity key, to indicate that authenticating with a key
  80. certified by the Ed25519 key counts as certifying with RSA
  81. identity key. (The signature is computed on the SHA256 hash of
  82. the non-signature parts of the certificate, prefixed with the
  83. string "Tor TLS RSA/Ed25519 cross-certificate".)
  84. This certificate type is used to mean, "This Ed25519 identity key
  85. acts with the authority of the RSA key that signed this
  86. certificate."
  87. A.1. List of certificate types
  88. The values marked with asterisks are not types corresponding to
  89. the certificate format of section 2.1. Instead, they are
  90. reserved for RSA-signed certificates to avoid conflicts between
  91. the certificate type enumeration of the CERTS cell and the
  92. certificate type enumeration of in our Ed25519 certificates.
  93. **[00],[01],[02],[03] - Reserved to avoid conflict with types used
  94. in CERTS cells.
  95. [04] - Ed25519 signing key with an identity key
  96. (see prop220 section 4.2)
  97. [05] - TLS link certificate signed with ed25519 signing key
  98. (see prop220 section 4.2)
  99. [06] - Ed25519 authentication key signed with ed25519 signing key
  100. (see prop220 section 4.2)
  101. **[07] - Reserved for RSA identity cross-certification;
  102. (see section 2.3 above, and tor-spec.txt section 4.2)
  103. [08] - Onion service: short-term descriptor signing key, signed
  104. with blinded public key.
  105. (See rend-spec-v3.txt, section [DESC_OUTER])
  106. [09] - Onion service: intro point authentication key, cross-certifying the
  107. descriptor signing key.
  108. (See rend-spec-v3.txt, description of "auth-key")
  109. [0A] - ntor onion key cross-certifying ed25519 identity key
  110. (see dir-spec.txt, description of "ntor-onion-key-crosscert")
  111. [0B] - Onion service: ntor-extra encryption key, cross-certifying
  112. descriptor signing key.
  113. (see rend-spec-v3.txt, description of "enc-key-cert")
  114. A.2. List of extension types
  115. [01] - signed-with-ed25519-key (section 2.2.1)
  116. A.3. List of signature prefixes
  117. We describe various documents as being signed with a prefix. Here
  118. are those prefixes:
  119. "Tor router descriptor signature v1" (see dir-spec.txt)
  120. A.4. List of certified key types
  121. [01] ed25519 key
  122. [02] SHA256 hash of an RSA key
  123. [03] SHA256 hash of an X.509 certificate
  124. [08] short-term HS descriptor signing key, signed with blinded public key (rend-spec-v3.txt)
  125. [09] intro point authentication key, cross-certifying the HS descriptor
  126. signing key (rend-spec-v3.txt)
  127. [0B] ed25519 key derived from the curve25519 intro point encryption key,
  128. cross-certifying the HS descriptor signing key (rend-spec-v3.txt)