PROTOCOL.sshsig 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. This document describes a lightweight SSH Signature format
  2. that is compatible with SSH keys and wire formats.
  3. At present, only detached and armored signatures are supported.
  4. 1. Armored format
  5. The Armored SSH signatures consist of a header, a base64
  6. encoded blob, and a footer.
  7. The header is the string "-----BEGIN SSH SIGNATURE-----"
  8. followed by a newline. The footer is the string
  9. "-----END SSH SIGNATURE-----" immediately after a newline.
  10. The header MUST be present at the start of every signature.
  11. Files containing the signature MUST start with the header.
  12. Likewise, the footer MUST be present at the end of every
  13. signature.
  14. The base64 encoded blob SHOULD be broken up by newlines
  15. every 76 characters.
  16. Example:
  17. -----BEGIN SSH SIGNATURE-----
  18. U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgJKxoLBJBivUPNTUJUSslQTt2hD
  19. jozKvHarKeN8uYFqgAAAADZm9vAAAAAAAAAFMAAAALc3NoLWVkMjU1MTkAAABAKNC4IEbt
  20. Tq0Fb56xhtuE1/lK9H9RZJfON4o6hE9R4ZGFX98gy0+fFJ/1d2/RxnZky0Y7GojwrZkrHT
  21. FgCqVWAQ==
  22. -----END SSH SIGNATURE-----
  23. 2. Blob format
  24. #define MAGIC_PREAMBLE "SSHSIG"
  25. #define SIG_VERSION 0x01
  26. byte[6] MAGIC_PREAMBLE
  27. uint32 SIG_VERSION
  28. string publickey
  29. string namespace
  30. string reserved
  31. string hash_algorithm
  32. string signature
  33. The publickey field MUST contain the serialisation of the
  34. public key used to make the signature using the usual SSH
  35. encoding rules, i.e RFC4253, RFC5656,
  36. draft-ietf-curdle-ssh-ed25519-ed448, etc.
  37. Verifiers MUST reject signatures with versions greater than those
  38. they support.
  39. The purpose of the namespace value is to specify a unambiguous
  40. interpretation domain for the signature, e.g. file signing.
  41. This prevents cross-protocol attacks caused by signatures
  42. intended for one intended domain being accepted in another.
  43. The namespace value MUST NOT be the empty string.
  44. The reserved value is present to encode future information
  45. (e.g. tags) into the signature. Implementations should ignore
  46. the reserved field if it is not empty.
  47. Data to be signed is first hashed with the specified hash_algorithm.
  48. This is done to limit the amount of data presented to the signature
  49. operation, which may be of concern if the signing key is held in limited
  50. or slow hardware or on a remote ssh-agent. The supported hash algorithms
  51. are "sha256" and "sha512".
  52. The signature itself is made using the SSH signature algorithm and
  53. encoding rules for the chosen key type. For RSA signatures, the
  54. signature algorithm must be "rsa-sha2-512" or "rsa-sha2-256" (i.e.
  55. not the legacy RSA-SHA1 "ssh-rsa").
  56. This blob is encoded as a string using the RFC4253 encoding
  57. rules and base64 encoded to form the middle part of the
  58. armored signature.
  59. 3. Signed Data, of which the signature goes into the blob above
  60. #define MAGIC_PREAMBLE "SSHSIG"
  61. byte[6] MAGIC_PREAMBLE
  62. string namespace
  63. string reserved
  64. string hash_algorithm
  65. string H(message)
  66. The preamble is the six-byte sequence "SSHSIG". It is included to
  67. ensure that manual signatures can never be confused with any message
  68. signed during SSH user or host authentication.
  69. The reserved value is present to encode future information
  70. (e.g. tags) into the signature. Implementations should ignore
  71. the reserved field if it is not empty.
  72. The data is concatenated and passed to the SSH signing
  73. function.
  74. $OpenBSD: PROTOCOL.sshsig,v 1.4 2020/08/31 00:17:41 djm Exp $