comparison signkey.c @ 1676:d5cdc60db08e

ext-info handling for server-sig-algs only client side is handled
author Matt Johnston <matt@ucc.asn.au>
date Tue, 19 May 2020 00:31:41 +0800
parents ae41624c2198
children 435cfb9ec96e
comparison
equal deleted inserted replaced
1675:ae41624c2198 1676:d5cdc60db08e
112 /* Special case for rsa-sha2-256. This could be generalised if more 112 /* Special case for rsa-sha2-256. This could be generalised if more
113 signature names are added that aren't 1-1 with public key names */ 113 signature names are added that aren't 1-1 with public key names */
114 const char* signature_name_from_type(enum signature_type type, unsigned int *namelen) { 114 const char* signature_name_from_type(enum signature_type type, unsigned int *namelen) {
115 #if DROPBEAR_RSA_SHA256 115 #if DROPBEAR_RSA_SHA256
116 if (type == DROPBEAR_SIGNATURE_RSA_SHA256) { 116 if (type == DROPBEAR_SIGNATURE_RSA_SHA256) {
117 *namelen = strlen(SSH_SIGNATURE_RSA_SHA256); 117 if (namelen) {
118 *namelen = strlen(SSH_SIGNATURE_RSA_SHA256);
119 }
118 return SSH_SIGNATURE_RSA_SHA256; 120 return SSH_SIGNATURE_RSA_SHA256;
119 } 121 }
120 #endif 122 #endif
121 #if DROPBEAR_RSA_SHA1 123 #if DROPBEAR_RSA_SHA1
122 if (type == DROPBEAR_SIGNATURE_RSA_SHA1) { 124 if (type == DROPBEAR_SIGNATURE_RSA_SHA1) {
123 *namelen = strlen(SSH_SIGNKEY_RSA); 125 if (namelen) {
126 *namelen = strlen(SSH_SIGNKEY_RSA);
127 }
124 return SSH_SIGNKEY_RSA; 128 return SSH_SIGNKEY_RSA;
125 } 129 }
126 #endif 130 #endif
127 return signkey_name_from_type((enum signkey_type)type, namelen); 131 return signkey_name_from_type((enum signkey_type)type, namelen);
128 } 132 }
140 && memcmp(name, SSH_SIGNKEY_RSA, namelen) == 0) { 144 && memcmp(name, SSH_SIGNKEY_RSA, namelen) == 0) {
141 return DROPBEAR_SIGNATURE_RSA_SHA1; 145 return DROPBEAR_SIGNATURE_RSA_SHA1;
142 } 146 }
143 #endif 147 #endif
144 return (enum signature_type)signkey_type_from_name(name, namelen); 148 return (enum signature_type)signkey_type_from_name(name, namelen);
149 }
150
151 /* Returns the signature type from a key type. Must not be called
152 with RSA keytype */
153 enum signature_type signature_type_from_signkey(enum signkey_type keytype) {
154 #if DROPBEAR_RSA
155 assert(keytype != DROPBEAR_SIGNKEY_RSA);
156 #endif
157 assert(keytype < DROPBEAR_SIGNKEY_NUM_NAMED);
158 return (enum signature_type)keytype;
145 } 159 }
146 160
147 enum signkey_type signkey_type_from_signature(enum signature_type sigtype) { 161 enum signkey_type signkey_type_from_signature(enum signature_type sigtype) {
148 #if DROPBEAR_RSA_SHA256 162 #if DROPBEAR_RSA_SHA256
149 if (sigtype == DROPBEAR_SIGNATURE_RSA_SHA256) { 163 if (sigtype == DROPBEAR_SIGNATURE_RSA_SHA256) {
585 buffer *sigblob = buf_new(MAX_PUBKEY_SIZE); 599 buffer *sigblob = buf_new(MAX_PUBKEY_SIZE);
586 enum signkey_type keytype = signkey_type_from_signature(sigtype); 600 enum signkey_type keytype = signkey_type_from_signature(sigtype);
587 601
588 #if DEBUG_TRACE 602 #if DEBUG_TRACE
589 { 603 {
590 int namelen; 604 const char* signame = signature_name_from_type(sigtype, NULL);
591 const char* signame = signature_name_from_type(sigtype, &namelen);
592 TRACE(("buf_put_sign type %d %s", sigtype, signame)); 605 TRACE(("buf_put_sign type %d %s", sigtype, signame));
593 } 606 }
594 #endif 607 #endif
595 608
596 609