aboutsummaryrefslogtreecommitdiff
path: root/src/pki_mbedcrypto.c
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2018-08-06 14:32:28 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-08-31 14:18:34 +0200
commitb4c8bd9fe436c16956fb32574b3ec5928d601a82 (patch)
treefaf0dc28b61b74a418dc672246c5692a6cc51d5c /src/pki_mbedcrypto.c
parent5d1300665061736c3ebfb4728ee1a96a2a345f3f (diff)
downloadlibssh-b4c8bd9fe436c16956fb32574b3ec5928d601a82.tar.gz
libssh-b4c8bd9fe436c16956fb32574b3ec5928d601a82.tar.xz
libssh-b4c8bd9fe436c16956fb32574b3ec5928d601a82.zip
pki: Support RSA SHA2 signatures of sessionid for server
This involves mostly creation of host keys proofs but needs to follow the same procedure as the client authentication signatures. At the same time, the SHA2 extension is enabled in the pkd so we are able to atomicaly provide correct signatures and pass tests. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/pki_mbedcrypto.c')
-rw-r--r--src/pki_mbedcrypto.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/pki_mbedcrypto.c b/src/pki_mbedcrypto.c
index 68a80b42..fceacd80 100644
--- a/src/pki_mbedcrypto.c
+++ b/src/pki_mbedcrypto.c
@@ -1127,22 +1127,32 @@ ssh_signature pki_do_sign_hash(const ssh_key privkey,
}
#ifdef WITH_SERVER
-ssh_signature pki_do_sign_sessionid(const ssh_key key, const unsigned char
- *hash, size_t hlen)
+ssh_signature pki_do_sign_sessionid_hash(const ssh_key key,
+ const unsigned char *hash,
+ size_t hlen,
+ enum ssh_digest_e hash_type)
{
ssh_signature sig = NULL;
int rc;
+ /* Only RSA supports different signature algorithm types now */
+ if (key->type != SSH_KEYTYPE_RSA && hash_type != SSH_DIGEST_AUTO) {
+ SSH_LOG(SSH_LOG_WARN, "Incompatible signature algorithm passed");
+ return NULL;
+ }
+
sig = ssh_signature_new();
if (sig == NULL) {
return NULL;
}
+
sig->type = key->type;
sig->type_c = key->type_c;
switch (key->type) {
case SSH_KEYTYPE_RSA:
- sig->rsa_sig = rsa_do_sign_hash(hash, hlen, key->rsa, SSH_DIGEST_AUTO);
+ sig->type_c = ssh_key_signature_to_char(key->type, hash_type);
+ sig->rsa_sig = rsa_do_sign_hash(hash, hlen, key->rsa, hash_type);
if (sig->rsa_sig == NULL) {
ssh_signature_free(sig);
return NULL;