API Reference
Signature Verification
sshsig.sshsig.check_signature(msg_in, armored_signature, namespace='git')
Check that an ssh-keygen signature is a digital signature of the input message.
This function implements functionality provided by:
ssh-keygen -Y check-novalidate -n namespace -s armored_signature_file < msg_in
Returns:
Type | Description |
---|---|
PublicKey
|
The cryptographic PublicKey embedded inside the SSHSIG signature. |
Raises:
Type | Description |
---|---|
InvalidSignature
|
If signature is not valid for the input message. |
NotImplementedError
|
If a signature encoding feature is not supported. |
Source code in sshsig/sshsig.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
|
sshsig.sshsig.verify(msg_in, armored_signature, allowed_signers, namespace='git')
Verify a signature generated by ssh-keygen, the OpenSSH authentication key utility.
This function implements a SUBSET of functionality provided by:
ssh-keygen -Y verify \
-f allowed_signers_file \
-I '*' \
-n namespace \
-s armored_signature_file \
< msg_in
when the allowed_signers_file is in a sub-format with only lines starting:
* namespaces="X" ...
where X equals the namespace argument.
Returns:
Type | Description |
---|---|
PublicKey
|
The cryptographic PublicKey embedded inside the SSHSIG signature. |
Raises:
Type | Description |
---|---|
InvalidSignature
|
If signature is not valid for the input message. |
NotImplementedError
|
If a signature encoding feature is not supported. |
Source code in sshsig/sshsig.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
SSH Public Key
sshsig.ssh_public_key.PublicKey
Bases: ABC
Source code in sshsig/ssh_public_key.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
from_openssh_str(line)
classmethod
Create PublicKey from an OpenSSH format public key string.
Returns:
Type | Description |
---|---|
PublicKey
|
PublicKey |
Raises:
Type | Description |
---|---|
ValueError
|
If the input string is not a valid format or encoding. |
NotImplementedError
|
If the public key algorithm is not supported. |
Source code in sshsig/ssh_public_key.py
90 91 92 93 94 95 96 97 98 99 100 101 |
|
Allowed Signers File Format
Parsing of the ssh-keygen allowed signers format.
load_allowed_signers_file(file)
Read public keys in "allowed signers" format per ssh-keygen.
Raises:
Type | Description |
---|---|
ValueError
|
If the file is not properly formatted. |
Source code in sshsig/allowed_signers.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
for_git_allowed_keys(allowed_signers)
Convert ssh-keygen "allowed signers" entries to "just-a-list-for-git" sub-format.
In the "just-a-list-for-git" sub-format, only the "*" value is accepted in the principles field. The only allowed signers option accepted is 'namespaces="git"'.
Raises:
Type | Description |
---|---|
ValueError
|
If any ssh-keygen "allowed signers" feature is used that is not valid in the "just-a-list-for-git" sub-format. |
NotImplementedError
|
If a public key algorithm is not supported. |
Source code in sshsig/allowed_signers.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
save_for_git_allowed_signers_file(src, out)
Save keys for git to "allowed signers" format per ssh-keygen.
Source code in sshsig/allowed_signers.py
176 177 178 179 180 181 182 183 184 185 186 |
|