changed all occurrences of unsigned char to byte (defined in defines.h) to make the code more precise about sizes.

This commit is contained in:
git@daemon.de
2014-02-25 11:09:58 +01:00
parent cbc45f5fa1
commit 3b1db06529
31 changed files with 243 additions and 240 deletions

View File

@@ -26,7 +26,7 @@ int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd, i
FILE *in = NULL;
FILE *out = NULL;
pcp_key_t *secret = NULL;
unsigned char *symkey = NULL;
byte *symkey = NULL;
size_t dlen;
uint8_t head;
@@ -53,7 +53,7 @@ int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd, i
if(!feof(in) && !ferror(in)) {
if(head == PCP_SYM_CIPHER) {
/* symetric mode */
unsigned char *salt = ucmalloc(90);
byte *salt = ucmalloc(90);
char stsalt[] = PBP_COMPAT_SALT;
memcpy(salt, stsalt, 90);
@@ -143,7 +143,7 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec
pcp_pubkey_t *tmp = NULL;
pcp_pubkey_t *pub = NULL;
pcp_key_t *secret = NULL;
unsigned char *symkey = NULL;
byte *symkey = NULL;
int self = 0;
if(id == NULL && recipient == NULL) {
@@ -158,7 +158,7 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec
passphrase = ucmalloc(strlen(passwd)+1);
strncpy(passphrase, passwd, strlen(passwd)+1);
}
unsigned char *salt = ucmalloc(90); /* FIXME: use random salt, concat it with result afterwards */
byte *salt = ucmalloc(90); /* FIXME: use random salt, concat it with result afterwards */
char stsalt[] = PBP_COMPAT_SALT;
memcpy(salt, stsalt, 90);
symkey = pcp_scrypt(passphrase, crypto_secretbox_KEYBYTES, salt, 90);

View File

@@ -429,7 +429,7 @@ void pcp_exportpublic(char *keyid, char *passwd, char *outfile, int format, int
int pcp_importsecret (vault_t *vault, FILE *in, char *passwd) {
unsigned char *buf = ucmalloc(2048);
byte *buf = ucmalloc(2048);
size_t buflen = fread(buf, 1, 2048, in);
pcp_key_t *sk = NULL;
@@ -511,7 +511,7 @@ int pcp_importsecret (vault_t *vault, FILE *in, char *passwd) {
}
int pcp_importpublic (vault_t *vault, FILE *in) {
unsigned char *buf = ucmalloc(2048);
byte *buf = ucmalloc(2048);
size_t buflen = fread(buf, 1, 2048, in);
pcp_keysig_t *sk = NULL;
pcp_pubkey_t *pub = NULL;

View File

@@ -62,6 +62,6 @@ int pcp_importsecret (vault_t *vault, FILE *in, char *passwd);
void pcpdelete_key(char *keyid);
char *pcp_find_id_byrec(char *recipient);
void pcpedit_key(char *keyid);
#endif /* _HAVE_KEYMGMT_H */

View File

@@ -57,7 +57,7 @@ int pcptext_infile(char *infile) {
}
size_t clen;
unsigned char *bin = pcp_z85_decode((char *)z85, &clen);
byte *bin = pcp_z85_decode((char *)z85, &clen);
free(z85);
if(bin == NULL) {
@@ -159,7 +159,7 @@ void pcppubkey_print(pcp_pubkey_t *key, FILE* out) {
c->tm_year+1900, c->tm_mon+1, c->tm_mday,
c->tm_hour, c->tm_min, c->tm_sec);
unsigned char *hash = pcppubkey_getchecksum(key);
byte *hash = pcppubkey_getchecksum(key);
fprintf(out, " Checksum: ");
int i;
@@ -311,7 +311,7 @@ void pcpexport_yaml(char *outfile) {
}
}
void pcpprint_bin(FILE *out, unsigned char *data, size_t len) {
void pcpprint_bin(FILE *out, byte *data, size_t len) {
int i;
for ( i = 0;i < len;++i)
fprintf(out, "%02x", (unsigned int) data[i]);

View File

@@ -45,6 +45,6 @@ void pcptext_vault(vault_t *vault);
int pcptext_infile(char *infile);
void pcpexport_yaml(char *outfile);
void pcpprint_bin(FILE *out, unsigned char *data, size_t len);
void pcpprint_bin(FILE *out, byte *data, size_t len);
#endif /* _HAVE_PCP_KEYPRINT_H */

View File

@@ -44,16 +44,16 @@ int pcpz85_encode(char *infile, char *outfile) {
}
}
unsigned char *input = NULL;
byte *input = NULL;
size_t inputBufSize = 0;
unsigned char byte[1];
byte onebyte[1];
while(!feof(in)) {
if(!fread(&byte, 1, 1, in))
if(!fread(&onebyte, 1, 1, in))
break;
unsigned char *tmp = realloc(input, inputBufSize + 1);
byte *tmp = realloc(input, inputBufSize + 1);
input = tmp;
memmove(&input[inputBufSize], byte, 1);
memmove(&input[inputBufSize], onebyte, 1);
inputBufSize ++;
}
fclose(in);
@@ -115,7 +115,7 @@ int pcpz85_decode(char *infile, char *outfile) {
goto errdz1;
size_t clen;
unsigned char *decoded = pcp_z85_decode(encoded, &clen);
byte *decoded = pcp_z85_decode(encoded, &clen);