# HG changeset patch # User Matt Johnston # Date 1368113139 -28800 # Node ID 30f7bad5e74833c0659564422f3ea0bc018404a8 # Parent 069b875031f59c3e1912f44d649a34ea2b362e53# Parent 45f1bc96f35784831566532ae6de4ef10e64bffc merge diff -r 069b875031f5 -r 30f7bad5e748 dropbearkey.c --- a/dropbearkey.c Thu May 09 23:24:05 2013 +0800 +++ b/dropbearkey.c Thu May 09 23:25:39 2013 +0800 @@ -76,7 +76,7 @@ " 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 @@ } // 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 */ } } diff -r 069b875031f5 -r 30f7bad5e748 ecdsa.h --- a/ecdsa.h Thu May 09 23:24:05 2013 +0800 +++ b/ecdsa.h Thu May 09 23:25:39 2013 +0800 @@ -5,6 +5,8 @@ #include "buffer.h" #include "signkey.h" +#ifdef DROPBEAR_ECDSA + #ifdef DROPBEAR_ECC_256 #define ECDSA_DEFAULT_SIZE 256 #elif DROPBEAR_ECC_384 @@ -25,4 +27,6 @@ void buf_put_ecdsa_sign(buffer *buf, ecc_key *key, buffer *data_buf); int buf_ecdsa_verify(buffer *buf, ecc_key *key, buffer *data_buf); -#endif // _ECDSA_H_ \ No newline at end of file +#endif + +#endif // _ECDSA_H_