Mercurial > dropbear
comparison keyimport.c @ 73:0bf5cebe622c
Dropbearkey can now print out pubkey portions
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 14 Aug 2004 17:35:28 +0000 |
parents | fe6bca95afa7 |
children | 680a0bc9df0a |
comparison
equal
deleted
inserted
replaced
72:9597c2e3b9d4 | 73:0bf5cebe622c |
---|---|
107 | 107 |
108 static sign_key *dropbear_read(const char* filename) { | 108 static sign_key *dropbear_read(const char* filename) { |
109 | 109 |
110 buffer * buf = NULL; | 110 buffer * buf = NULL; |
111 int len, maxlen; | 111 int len, maxlen; |
112 FILE *fp; | 112 FILE *fp = NULL; |
113 sign_key *ret = NULL; | 113 sign_key *ret = NULL; |
114 int type; | 114 int type; |
115 | 115 |
116 buf = buf_new(2000); | 116 buf = buf_new(MAX_PRIVKEY_SIZE); |
117 /* can't use buf_readfile since we might have "-" as filename */ | 117 /* buf_readfile knows about "-" */ |
118 if (strlen(filename) == 1 && filename[0] == '-') { | 118 if (buf_readfile(buf, filename) == DROPBEAR_FAILURE) { |
119 fp = stdin; | 119 goto error; |
120 } else { | 120 } |
121 fp = fopen(filename, "r"); | |
122 } | |
123 if (!fp) { | |
124 goto error; | |
125 } | |
126 | |
127 do { | |
128 maxlen = buf->size - buf->pos; | |
129 len = fread(buf_getwriteptr(buf, maxlen), 1, maxlen, fp); | |
130 buf_incrwritepos(buf, len); | |
131 } while (len != maxlen && len > 0); | |
132 | |
133 fclose(fp); | |
134 | 121 |
135 buf_setpos(buf, 0); | 122 buf_setpos(buf, 0); |
136 ret = new_sign_key(); | 123 ret = new_sign_key(); |
137 | 124 |
138 type = DROPBEAR_SIGNKEY_ANY; | 125 type = DROPBEAR_SIGNKEY_ANY; |
171 if (key->dsskey != NULL) { | 158 if (key->dsskey != NULL) { |
172 keytype = DROPBEAR_SIGNKEY_DSS; | 159 keytype = DROPBEAR_SIGNKEY_DSS; |
173 } | 160 } |
174 #endif | 161 #endif |
175 | 162 |
176 buf = buf_new(2000); | 163 buf = buf_new(MAX_PRIVKEY_SIZE); |
177 buf_put_priv_key(buf, key, keytype); | 164 buf_put_priv_key(buf, key, keytype); |
178 | 165 |
179 if (strlen(filename) == 1 && filename[0] == '-') { | 166 if (strlen(filename) == 1 && filename[0] == '-') { |
180 fp = stdout; | 167 fp = stdout; |
181 } else { | 168 } else { |