Mercurial > dropbear
comparison keyimport.c @ 1295:750ec4ec4cbe
Convert #ifdef to #if, other build changes
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 04 May 2016 15:33:40 +0200 |
parents | 56aba7dedbea |
children | 2c9dac2d6707 |
comparison
equal
deleted
inserted
replaced
1294:56aba7dedbea | 1295:750ec4ec4cbe |
---|---|
34 #include "bignum.h" | 34 #include "bignum.h" |
35 #include "buffer.h" | 35 #include "buffer.h" |
36 #include "dbutil.h" | 36 #include "dbutil.h" |
37 #include "ecc.h" | 37 #include "ecc.h" |
38 | 38 |
39 #ifdef DROPBEAR_ECDSA | 39 #if DROPBEAR_ECDSA |
40 static const unsigned char OID_SEC256R1_BLOB[] = {0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07}; | 40 static const unsigned char OID_SEC256R1_BLOB[] = {0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07}; |
41 static const unsigned char OID_SEC384R1_BLOB[] = {0x2b, 0x81, 0x04, 0x00, 0x22}; | 41 static const unsigned char OID_SEC384R1_BLOB[] = {0x2b, 0x81, 0x04, 0x00, 0x22}; |
42 static const unsigned char OID_SEC521R1_BLOB[] = {0x2b, 0x81, 0x04, 0x00, 0x23}; | 42 static const unsigned char OID_SEC521R1_BLOB[] = {0x2b, 0x81, 0x04, 0x00, 0x23}; |
43 #endif | 43 #endif |
44 | 44 |
600 /* | 600 /* |
601 * Space to create key blob in. | 601 * Space to create key blob in. |
602 */ | 602 */ |
603 blobbuf = buf_new(3000); | 603 blobbuf = buf_new(3000); |
604 | 604 |
605 #ifdef DROPBEAR_DSS | 605 #if DROPBEAR_DSS |
606 if (key->type == OSSH_DSA) { | 606 if (key->type == OSSH_DSA) { |
607 buf_putstring(blobbuf, "ssh-dss", 7); | 607 buf_putstring(blobbuf, "ssh-dss", 7); |
608 retkey->type = DROPBEAR_SIGNKEY_DSS; | 608 retkey->type = DROPBEAR_SIGNKEY_DSS; |
609 } | 609 } |
610 #endif | 610 #endif |
611 #ifdef DROPBEAR_RSA | 611 #if DROPBEAR_RSA |
612 if (key->type == OSSH_RSA) { | 612 if (key->type == OSSH_RSA) { |
613 buf_putstring(blobbuf, "ssh-rsa", 7); | 613 buf_putstring(blobbuf, "ssh-rsa", 7); |
614 retkey->type = DROPBEAR_SIGNKEY_RSA; | 614 retkey->type = DROPBEAR_SIGNKEY_RSA; |
615 } | 615 } |
616 #endif | 616 #endif |
666 | 666 |
667 /* Skip past the number. */ | 667 /* Skip past the number. */ |
668 p += len; | 668 p += len; |
669 } | 669 } |
670 | 670 |
671 #ifdef DROPBEAR_ECDSA | 671 #if DROPBEAR_ECDSA |
672 if (key->type == OSSH_EC) { | 672 if (key->type == OSSH_EC) { |
673 unsigned char* private_key_bytes = NULL; | 673 unsigned char* private_key_bytes = NULL; |
674 int private_key_len = 0; | 674 int private_key_len = 0; |
675 unsigned char* public_key_bytes = NULL; | 675 unsigned char* public_key_bytes = NULL; |
676 int public_key_len = 0; | 676 int public_key_len = 0; |
713 errmsg = "ASN.1 decoding failure"; | 713 errmsg = "ASN.1 decoding failure"; |
714 goto error; | 714 goto error; |
715 } | 715 } |
716 | 716 |
717 if (0) {} | 717 if (0) {} |
718 #ifdef DROPBEAR_ECC_256 | 718 #if DROPBEAR_ECC_256 |
719 else if (len == sizeof(OID_SEC256R1_BLOB) | 719 else if (len == sizeof(OID_SEC256R1_BLOB) |
720 && memcmp(p, OID_SEC256R1_BLOB, len) == 0) { | 720 && memcmp(p, OID_SEC256R1_BLOB, len) == 0) { |
721 retkey->type = DROPBEAR_SIGNKEY_ECDSA_NISTP256; | 721 retkey->type = DROPBEAR_SIGNKEY_ECDSA_NISTP256; |
722 curve = &ecc_curve_nistp256; | 722 curve = &ecc_curve_nistp256; |
723 } | 723 } |
724 #endif | 724 #endif |
725 #ifdef DROPBEAR_ECC_384 | 725 #if DROPBEAR_ECC_384 |
726 else if (len == sizeof(OID_SEC384R1_BLOB) | 726 else if (len == sizeof(OID_SEC384R1_BLOB) |
727 && memcmp(p, OID_SEC384R1_BLOB, len) == 0) { | 727 && memcmp(p, OID_SEC384R1_BLOB, len) == 0) { |
728 retkey->type = DROPBEAR_SIGNKEY_ECDSA_NISTP384; | 728 retkey->type = DROPBEAR_SIGNKEY_ECDSA_NISTP384; |
729 curve = &ecc_curve_nistp384; | 729 curve = &ecc_curve_nistp384; |
730 } | 730 } |
731 #endif | 731 #endif |
732 #ifdef DROPBEAR_ECC_521 | 732 #if DROPBEAR_ECC_521 |
733 else if (len == sizeof(OID_SEC521R1_BLOB) | 733 else if (len == sizeof(OID_SEC521R1_BLOB) |
734 && memcmp(p, OID_SEC521R1_BLOB, len) == 0) { | 734 && memcmp(p, OID_SEC521R1_BLOB, len) == 0) { |
735 retkey->type = DROPBEAR_SIGNKEY_ECDSA_NISTP521; | 735 retkey->type = DROPBEAR_SIGNKEY_ECDSA_NISTP521; |
736 curve = &ecc_curve_nistp521; | 736 curve = &ecc_curve_nistp521; |
737 } | 737 } |
830 char *header = NULL, *footer = NULL; | 830 char *header = NULL, *footer = NULL; |
831 char zero[1]; | 831 char zero[1]; |
832 int ret = 0; | 832 int ret = 0; |
833 FILE *fp; | 833 FILE *fp; |
834 | 834 |
835 #ifdef DROPBEAR_RSA | 835 #if DROPBEAR_RSA |
836 mp_int dmp1, dmq1, iqmp, tmpval; /* for rsa */ | 836 mp_int dmp1, dmq1, iqmp, tmpval; /* for rsa */ |
837 #endif | 837 #endif |
838 | 838 |
839 if ( | 839 if ( |
840 #ifdef DROPBEAR_RSA | 840 #if DROPBEAR_RSA |
841 key->type == DROPBEAR_SIGNKEY_RSA || | 841 key->type == DROPBEAR_SIGNKEY_RSA || |
842 #endif | 842 #endif |
843 #ifdef DROPBEAR_DSS | 843 #if DROPBEAR_DSS |
844 key->type == DROPBEAR_SIGNKEY_DSS || | 844 key->type == DROPBEAR_SIGNKEY_DSS || |
845 #endif | 845 #endif |
846 0) | 846 0) |
847 { | 847 { |
848 /* | 848 /* |
1024 memcpy(outblob+pos, numbers[i].start, numbers[i].bytes); | 1024 memcpy(outblob+pos, numbers[i].start, numbers[i].bytes); |
1025 pos += numbers[i].bytes; | 1025 pos += numbers[i].bytes; |
1026 } | 1026 } |
1027 } /* end RSA and DSS handling */ | 1027 } /* end RSA and DSS handling */ |
1028 | 1028 |
1029 #ifdef DROPBEAR_ECDSA | 1029 #if DROPBEAR_ECDSA |
1030 if (key->type == DROPBEAR_SIGNKEY_ECDSA_NISTP256 | 1030 if (key->type == DROPBEAR_SIGNKEY_ECDSA_NISTP256 |
1031 || key->type == DROPBEAR_SIGNKEY_ECDSA_NISTP384 | 1031 || key->type == DROPBEAR_SIGNKEY_ECDSA_NISTP384 |
1032 || key->type == DROPBEAR_SIGNKEY_ECDSA_NISTP521) { | 1032 || key->type == DROPBEAR_SIGNKEY_ECDSA_NISTP521) { |
1033 | 1033 |
1034 /* SEC1 V2 appendix c.4 | 1034 /* SEC1 V2 appendix c.4 |