Skip to content

AgentSSH - sign_ssh_data can take optional flags to indicate hashalg - #1644

Closed
commonism wants to merge 1 commit into
paramiko:mainfrom
commonism:agentsignflags
Closed

commonism wants to merge 1 commit into
paramiko:mainfrom
commonism:agentsignflags

Conversation

@commonism

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread paramiko/agent.py
Sign a blob of data with this private key, and return a `.Message`
representing an SSH signature message.

Use flags to sign using sha2-256 or sha2-512, default is sha1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default is sha1 only for rsa keys, not for ecdsa or ed25519, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. flags are not defined for anything but ssh-rsa.

@ploxiln

ploxiln commented Mar 23, 2020

Copy link
Copy Markdown
Contributor

How might this be used? This seems like just one needed part, at least for a client with an rsa key for user auth.

To auth with key, one calls Transport.auth_publickey() (or SSHClient calls that for you), and I think that eventually ends up in AuthHandler._parse_service_accept() where sign_ssh_data() is called (and the key type name is embedded in the message there too). So that would need to know that for "ssh-rsa" keys, if it is using an AgentKey, it can call sign_ssh_data() with flag, and change the name from "ssh-rsa" to the appropriate sha2 variant?

Maybe the easier way to use this in paramiko, is to have the agent create 3 keys when it sees an rsa key, one for each hash algo variant. Each AgentKey reports its variant name, and automatically passes the appropriate flag to the agent when sign_ssh_data() is called, so sign_ssh_data() can keep the same method signature as on every other key type.

Just thinking out-loud ...

@commonism

commonism commented Mar 23, 2020 •

Copy link
Copy Markdown
Contributor Author

I'm not looking for ssh authentication with this one. I just need to sign.
Sign data without having key and data in a single place by forwarding access to the key via ssh.

Used here:
m32/endesive#42
m32/endesive#43
m32/endesive#45

@ploxiln

ploxiln commented Mar 23, 2020

Copy link
Copy Markdown
Contributor

I see. Anyway, this is a useful reference/hint for implementing SSH auth, thanks.

@bitprophet

Copy link
Copy Markdown
Member

See #1643 (though I ended up writing my own branch for this). Releasing soon. Thanks!

@bitprophet bitprophet closed this Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants