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