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