summaryrefslogtreecommitdiffhomepage
path: root/dropbearkey.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2013-05-09 23:25:39 +0800
committerMatt Johnston <matt@ucc.asn.au>2013-05-09 23:25:39 +0800
commitb46d46667fd1f9b93f237fc0b054425609bd717d (patch)
tree4e17e29ce172c0def14ddbd715264dd47a5c2e09 /dropbearkey.c
parent916cfa6b830f5862d036448ce7b26398d87253b4 (diff)
parent226671b5508afb147cad40d5cd8f90e1cbb2c24e (diff)
merge
--HG-- branch : ecc
Diffstat (limited to 'dropbearkey.c')
-rw-r--r--dropbearkey.c57
1 files changed, 39 insertions, 18 deletions
diff --git a/dropbearkey.c b/dropbearkey.c
index 8bc114c..1d3dfe7 100644
--- a/dropbearkey.c
+++ b/dropbearkey.c
@@ -76,7 +76,7 @@ static void printhelp(char * progname) {
" dss\n"
#endif
#ifdef DROPBEAR_ECDSA
- " ecdsa\n"
+ " ecdsa\n"
#endif
"-f filename Use filename for the secret key\n"
"-s bits Key size in bits, should be a multiple of 8 (optional)\n"
@@ -200,23 +200,44 @@ int main(int argc, char ** argv) {
}
// TODO: put RSA and DSS size checks into genrsa.c etc
- if (keytype == DROPBEAR_SIGNKEY_DSS && bits != 1024) {
- fprintf(stderr, "DSS keys have a fixed size of 1024 bits\n");
- exit(EXIT_FAILURE);
- } else if (bits < 512 || bits > 4096 || (bits % 8 != 0)) {
- fprintf(stderr, "Bits must satisfy 512 <= bits <= 4096, and be a"
- " multiple of 8\n");
- exit(EXIT_FAILURE);
- }
- } else {
- if (keytype == DROPBEAR_SIGNKEY_DSS) {
- bits = DSS_DEFAULT_SIZE;
- } else if (keytype == DROPBEAR_SIGNKEY_RSA) {
- bits = RSA_DEFAULT_SIZE;
- } else if (keytype == DROPBEAR_SIGNKEY_ECDSA_KEYGEN) {
- bits = ECDSA_DEFAULT_SIZE;
- } else {
- exit(EXIT_FAILURE); /* not reached */
+ switch (keytype) {
+#ifdef DROPBEAR_RSA
+ case DROPBEAR_SIGNKEY_RSA:
+ if (bits < 512 || bits > 4096 || (bits % 8 != 0)) {
+ fprintf(stderr, "Bits must satisfy 512 <= bits <= 4096, and be a"
+ " multiple of 8\n");
+ exit(EXIT_FAILURE);
+ }
+ break;
+#endif
+#ifdef DROPEAR_DSS
+ case DROPBEAR_SIGNKEY_DSS:
+ if (bits != 1024) {
+ fprintf(stderr, "DSS keys have a fixed size of 1024 bits\n");
+ exit(EXIT_FAILURE);
+ }
+#endif
+ // pass. ecdsa handles checks itself
+ }
+
+ switch (keytype) {
+#ifdef DROPBEAR_RSA
+ case DROPBEAR_SIGNKEY_RSA:
+ bits = RSA_DEFAULT_SIZE;
+ break;
+#endif
+#ifdef DROPBEAR_DSS
+ case DROPBEAR_SIGNKEY_DSS:
+ bits = DSS_DEFAULT_SIZE;
+ break;
+#endif
+#ifdef DROPBEAR_ECDSA
+ case DROPBEAR_SIGNKEY_ECDSA_KEYGEN:
+ bits = ECDSA_DEFAULT_SIZE;
+ break;
+#endif
+ default:
+ exit(EXIT_FAILURE); /* not reached */
}
}