Open caarlos0 opened 1 month ago
I'd like to propose we support encoding and decoding SSHSIG signature format.
I already have a working implementation (armoring a *ssh.Signature and then parsing it back into the signed data), but I'm not sure what the api should look like.
*ssh.Signature
We have a couple of steps to create a signature:
To verify a signature, we need to:
publickey.Verify(blob, decodedBlod)
Given all this, I'd suggest the following functions:
func CreateBlob(r io.Reader) ([]byte, error) // or (io.Reader, error) func Encode(pk ssh.PublicKey, sig *ssh.Signature) ([]byte, error) // or (io.Reader, error) func Decode(r io.Reader) (*ssh.Signature, ssh.PublicKey, error)
We would also need these two structs:
// Blob according to the SSHSIG protocol. type Blob struct { Namespace string Reserved string HashAlgorithm string Hash string } // SignedData according to the SSHSIG protocol. type SignedData struct { MagicPreamble [6]byte Version uint32 PublicKey string Namespace string Reserved string HashAlgorithm string Signature string }
and some constants:
const ( magicPreamble = "SSHSIG" version = 1 namespace = "file" hashAlgorithm = "sha512" armorType = "SSH SIGNATURE" )
There's also the discussion of which hash algorithms to support... only rsa-sha2-512 or rsa-sha2-256, which I think it's easy enough to support both.
rsa-sha2-512
rsa-sha2-256
Finally, the namespace, not sure if we allow to customize that or not.
Anyway, I would love to work on this, just need some direction on how the API should look like.
CC @golang/security @drakkan
Proposal Details
I'd like to propose we support encoding and decoding SSHSIG signature format.
I already have a working implementation (armoring a
*ssh.Signature
and then parsing it back into the signed data), but I'm not sure what the api should look like.We have a couple of steps to create a signature:
To verify a signature, we need to:
publickey.Verify(blob, decodedBlod)
Given all this, I'd suggest the following functions:
We would also need these two structs:
and some constants:
There's also the discussion of which hash algorithms to support... only
rsa-sha2-512
orrsa-sha2-256
, which I think it's easy enough to support both.Finally, the namespace, not sure if we allow to customize that or not.
Anyway, I would love to work on this, just need some direction on how the API should look like.