comparison keyimport.c @ 849:754d7bee1068 ecc

Merge
author Matt Johnston <matt@ucc.asn.au>
date Fri, 08 Nov 2013 23:32:13 +0800
parents 6c69e7df3621 f4bb964c8678
children c19acba28590
comparison
equal deleted inserted replaced
848:6c69e7df3621 849:754d7bee1068
110 110
111 static sign_key *dropbear_read(const char* filename) { 111 static sign_key *dropbear_read(const char* filename) {
112 112
113 buffer * buf = NULL; 113 buffer * buf = NULL;
114 sign_key *ret = NULL; 114 sign_key *ret = NULL;
115 int type; 115 enum signkey_type type;
116 116
117 buf = buf_new(MAX_PRIVKEY_SIZE); 117 buf = buf_new(MAX_PRIVKEY_SIZE);
118 if (buf_readfile(buf, filename) == DROPBEAR_FAILURE) { 118 if (buf_readfile(buf, filename) == DROPBEAR_FAILURE) {
119 goto error; 119 goto error;
120 } 120 }
499 memset(&key, 0, sizeof(key)); 499 memset(&key, 0, sizeof(key));
500 m_free(key); 500 m_free(key);
501 return ret; 501 return ret;
502 } 502 }
503 503
504 static sign_key *openssh_read(const char *filename, char *passphrase) 504 static sign_key *openssh_read(const char *filename, char * UNUSED(passphrase))
505 { 505 {
506 struct openssh_key *key; 506 struct openssh_key *key;
507 unsigned char *p; 507 unsigned char *p;
508 int ret, id, len, flags; 508 int ret, id, len, flags;
509 int i, num_integers = 0; 509 int i, num_integers = 0;
510 sign_key *retval = NULL; 510 sign_key *retval = NULL;
511 char *errmsg; 511 char *errmsg;
512 char *modptr = NULL; 512 char *modptr = NULL;
513 int modlen = -9999; 513 int modlen = -9999;
514 int type; 514 enum signkey_type type;
515 515
516 sign_key *retkey; 516 sign_key *retkey;
517 buffer * blobbuf = NULL; 517 buffer * blobbuf = NULL;
518 518
519 retkey = new_sign_key(); 519 retkey = new_sign_key();
707 key->keyblob+key->keyblob_len-p < len) { 707 key->keyblob+key->keyblob_len-p < len) {
708 errmsg = "ASN.1 decoding failure"; 708 errmsg = "ASN.1 decoding failure";
709 goto error; 709 goto error;
710 } 710 }
711 711
712 if (len == sizeof(OID_SEC256R1_BLOB) 712 if (0) {}
713 #ifdef DROPBEAR_ECC_256
714 else if (len == sizeof(OID_SEC256R1_BLOB)
713 && memcmp(p, OID_SEC256R1_BLOB, len) == 0) { 715 && memcmp(p, OID_SEC256R1_BLOB, len) == 0) {
714 retkey->type = DROPBEAR_SIGNKEY_ECDSA_NISTP256; 716 retkey->type = DROPBEAR_SIGNKEY_ECDSA_NISTP256;
715 curve = &ecc_curve_nistp256; 717 curve = &ecc_curve_nistp256;
716 } else if (len == sizeof(OID_SEC384R1_BLOB) 718 }
719 #endif
720 #ifdef DROPBEAR_ECC_384
721 else if (len == sizeof(OID_SEC384R1_BLOB)
717 && memcmp(p, OID_SEC384R1_BLOB, len) == 0) { 722 && memcmp(p, OID_SEC384R1_BLOB, len) == 0) {
718 retkey->type = DROPBEAR_SIGNKEY_ECDSA_NISTP384; 723 retkey->type = DROPBEAR_SIGNKEY_ECDSA_NISTP384;
719 curve = &ecc_curve_nistp384; 724 curve = &ecc_curve_nistp384;
720 } else if (len == sizeof(OID_SEC521R1_BLOB) 725 }
726 #endif
727 #ifdef DROPBEAR_ECC_521
728 else if (len == sizeof(OID_SEC521R1_BLOB)
721 && memcmp(p, OID_SEC521R1_BLOB, len) == 0) { 729 && memcmp(p, OID_SEC521R1_BLOB, len) == 0) {
722 retkey->type = DROPBEAR_SIGNKEY_ECDSA_NISTP521; 730 retkey->type = DROPBEAR_SIGNKEY_ECDSA_NISTP521;
723 curve = &ecc_curve_nistp521; 731 curve = &ecc_curve_nistp521;
724 } else { 732 }
733 #endif
734 else {
725 errmsg = "Unknown ECC key type"; 735 errmsg = "Unknown ECC key type";
726 goto error; 736 goto error;
727 } 737 }
728 p += len; 738 p += len;
729 739
1017 publicKey [1] BIT STRING OPTIONAL 1027 publicKey [1] BIT STRING OPTIONAL
1018 } 1028 }
1019 */ 1029 */
1020 buffer *seq_buf = buf_new(400); 1030 buffer *seq_buf = buf_new(400);
1021 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, key->type); 1031 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, key->type);
1022 const unsigned long curve_size = (*eck)->dp->size; 1032 const long curve_size = (*eck)->dp->size;
1023 int curve_oid_len = 0; 1033 int curve_oid_len = 0;
1024 const void* curve_oid = NULL; 1034 const void* curve_oid = NULL;
1025 unsigned long pubkey_size = 2*curve_size+1; 1035 unsigned long pubkey_size = 2*curve_size+1;
1026 1036
1027 /* version. less than 10 bytes */ 1037 /* version. less than 10 bytes */