comparison keyimport.c @ 1459:06d52bcb8094

Pointer parameter could be declared as pointing to const
author Francois Perrad <francois.perrad@gadz.org>
date Sat, 19 Aug 2017 17:16:13 +0200
parents 77c0d57a4410
children 2d450c1056e3
comparison
equal deleted inserted replaced
1458:bdd3802c8ac6 1459:06d52bcb8094
53 ((unsigned long)(unsigned char)(cp)[1] << 16) | \ 53 ((unsigned long)(unsigned char)(cp)[1] << 16) | \
54 ((unsigned long)(unsigned char)(cp)[2] << 8) | \ 54 ((unsigned long)(unsigned char)(cp)[2] << 8) | \
55 ((unsigned long)(unsigned char)(cp)[3])) 55 ((unsigned long)(unsigned char)(cp)[3]))
56 56
57 static int openssh_encrypted(const char *filename); 57 static int openssh_encrypted(const char *filename);
58 static sign_key *openssh_read(const char *filename, char *passphrase); 58 static sign_key *openssh_read(const char *filename, const char *passphrase);
59 static int openssh_write(const char *filename, sign_key *key, 59 static int openssh_write(const char *filename, sign_key *key,
60 char *passphrase); 60 const char *passphrase);
61 61
62 static int dropbear_write(const char*filename, sign_key * key); 62 static int dropbear_write(const char*filename, sign_key * key);
63 static sign_key *dropbear_read(const char* filename); 63 static sign_key *dropbear_read(const char* filename);
64 64
65 static int toint(unsigned u); 65 static int toint(unsigned u);
81 #endif 81 #endif
82 } 82 }
83 return 0; 83 return 0;
84 } 84 }
85 85
86 sign_key *import_read(const char *filename, char *passphrase, int filetype) { 86 sign_key *import_read(const char *filename, const char *passphrase, int filetype) {
87 87
88 if (filetype == KEYFILE_OPENSSH) { 88 if (filetype == KEYFILE_OPENSSH) {
89 return openssh_read(filename, passphrase); 89 return openssh_read(filename, passphrase);
90 } else if (filetype == KEYFILE_DROPBEAR) { 90 } else if (filetype == KEYFILE_DROPBEAR) {
91 return dropbear_read(filename); 91 return dropbear_read(filename);
95 #endif 95 #endif
96 } 96 }
97 return NULL; 97 return NULL;
98 } 98 }
99 99
100 int import_write(const char *filename, sign_key *key, char *passphrase, 100 int import_write(const char *filename, sign_key *key, const char *passphrase,
101 int filetype) { 101 int filetype) {
102 102
103 if (filetype == KEYFILE_OPENSSH) { 103 if (filetype == KEYFILE_OPENSSH) {
104 return openssh_write(filename, key, passphrase); 104 return openssh_write(filename, key, passphrase);
105 } else if (filetype == KEYFILE_DROPBEAR) { 105 } else if (filetype == KEYFILE_DROPBEAR) {
192 ((c) >= '0' && (c) <= '9') || \ 192 ((c) >= '0' && (c) <= '9') || \
193 (c) == '+' || (c) == '/' || (c) == '=' \ 193 (c) == '+' || (c) == '/' || (c) == '=' \
194 ) 194 )
195 195
196 /* cpl has to be less than 100 */ 196 /* cpl has to be less than 100 */
197 static void base64_encode_fp(FILE * fp, unsigned char *data, 197 static void base64_encode_fp(FILE * fp, const unsigned char *data,
198 int datalen, int cpl) 198 int datalen, int cpl)
199 { 199 {
200 unsigned char out[100]; 200 unsigned char out[100];
201 int n; 201 int n;
202 unsigned long outlen; 202 unsigned long outlen;
507 m_free(key->keyblob); 507 m_free(key->keyblob);
508 m_free(key); 508 m_free(key);
509 return ret; 509 return ret;
510 } 510 }
511 511
512 static sign_key *openssh_read(const char *filename, char * UNUSED(passphrase)) 512 static sign_key *openssh_read(const char *filename, const char * UNUSED(passphrase))
513 { 513 {
514 struct openssh_key *key; 514 struct openssh_key *key;
515 unsigned char *p; 515 unsigned char *p;
516 int ret, id, len, flags; 516 int ret, id, len, flags;
517 int i, num_integers = 0; 517 int i, num_integers = 0;
826 } 826 }
827 return retval; 827 return retval;
828 } 828 }
829 829
830 static int openssh_write(const char *filename, sign_key *key, 830 static int openssh_write(const char *filename, sign_key *key,
831 char *passphrase) 831 const char *passphrase)
832 { 832 {
833 buffer * keyblob = NULL; 833 buffer * keyblob = NULL;
834 buffer * extrablob = NULL; /* used for calculated values to write */ 834 buffer * extrablob = NULL; /* used for calculated values to write */
835 unsigned char *outblob = NULL; 835 unsigned char *outblob = NULL;
836 int outlen = -9999; 836 int outlen = -9999;