diff options
author | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2015-07-23 10:05:45 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2015-07-27 12:39:33 +0000 |
commit | 8f5618c3ecc0daf971b19780646cc14a6db12931 (patch) | |
tree | 56825d5845ac8e3214ef363e6b6c2bcc31af79d3 /src/libs/ssh/sshcapabilities.cpp | |
parent | 851054dee8dd87b7333596b59459f798deca1dea (diff) |
SSH: Don't assume an exact width of ECDSA keys.
The number specified in the algorithm name is a maximum.
Change-Id: I70177a135be29adbf9b58d0dd3b9de339f0d3b7e
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src/libs/ssh/sshcapabilities.cpp')
-rw-r--r-- | src/libs/ssh/sshcapabilities.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libs/ssh/sshcapabilities.cpp b/src/libs/ssh/sshcapabilities.cpp index 6bef99b91d..6d368025bd 100644 --- a/src/libs/ssh/sshcapabilities.cpp +++ b/src/libs/ssh/sshcapabilities.cpp @@ -147,6 +147,18 @@ int SshCapabilities::ecdsaIntegerWidthInBytes(const QByteArray &ecdsaAlgo) .arg(QString::fromLatin1(ecdsaAlgo))); } +QByteArray SshCapabilities::ecdsaPubKeyAlgoForKeyWidth(int keyWidthInBytes) +{ + if (keyWidthInBytes <= 32) + return PubKeyEcdsa256; + if (keyWidthInBytes <= 48) + return PubKeyEcdsa384; + if (keyWidthInBytes <= 66) + return PubKeyEcdsa521; + throw SshClientException(SshInternalError, SSH_TR("Unexpected ecdsa key size (%1 bytes)") + .arg(keyWidthInBytes)); +} + const char *SshCapabilities::oid(const QByteArray &ecdsaAlgo) { if (ecdsaAlgo == PubKeyEcdsa256) |