SSH signatures
Sign and verify ssh-keygen -Y (sshsig) signatures.
Warning
Experimental: built on the pinned pre-release ssh-key 0.7.0-rc.12.
from oxcrypto.signature.ed25519 import ED25519
from oxcrypto.ssh.sshsig import SSHSIG
private_key = ED25519.ED25519.generate()
signature = SSHSIG.SHA512.sign(private_key, b"message", namespace="file")
assert SSHSIG.SHA512.verify(
private_key.public_key(), signature, b"message", namespace="file"
)SSHSIG implements OpenSSH PROTOCOL.sshsig, the format of ssh-keygen -Y sign, which Git uses for SSH commit signing. Variants name the message hash:
SHA256 and SHA512 (the ssh-keygen default). sign returns a
-----BEGIN SSH SIGNATURE----- PEM block. Ed25519, ECDSA P-256, P-384 and
P-521, and RSA keys sign; RSA signs with rsa-sha2-512.
verify returns True only if the signature is by public_key, uses this
variant's hash and was made over message in namespace. A malformed
signature returns False. The namespace separates uses of the same key
(ssh-keygen uses file and Git uses git) and must not be empty.