Commit 653b6675 authored by Mike Hibler's avatar Mike Hibler
Browse files

Fix some nits pointed out by a Linux build.

parent bb58a863
......@@ -16,6 +16,7 @@
#ifdef WITH_CRYPTO
#include <openssl/evp.h>
#include <openssl/sha.h>
#include <openssl/rsa.h>
#include "imagehdr.h"
#include "checksum.h"
......@@ -50,15 +51,15 @@ input_public_key(char *keyfile, RSA *key)
file = fopen(keyfile, "r");
fscanf(file, "%1024s", str);
BN_hex2bn(& key->n, str);
BN_hex2bn(&key->n, str);
fscanf(file, "%1024s", str);
BN_hex2bn(& key->e, str);
BN_hex2bn(&key->e, str);
fscanf(file, "%1024s", str);
BN_hex2bn(& key->dmp1, str);
BN_hex2bn(&key->dmp1, str);
fscanf(file, "%1024s", str);
BN_hex2bn(& key->dmq1, str);
BN_hex2bn(&key->dmq1, str);
fscanf(file, "%1024s", str);
BN_hex2bn(& key->iqmp, str);
BN_hex2bn(&key->iqmp, str);
fclose(file);
}
......@@ -97,7 +98,7 @@ decrypt_checksum(unsigned char *alleged_sum)
}
int
verify_checksum(blockhdr_t *blockhdr, const char *bodybufp)
verify_checksum(blockhdr_t *blockhdr, const unsigned char *bodybufp)
{
SHA_CTX sum_context;
int sum_length;
......@@ -183,7 +184,7 @@ encrypt_readkey(char *keyfile, unsigned char *keybuf, int buflen)
* into source. source must have 2*memsize + 1 bytes available.
*/
void
mem_to_hexstr(unsigned char *dest, const unsigned char *source, int memsize)
mem_to_hexstr(char *dest, const unsigned char *source, int memsize)
{
int i;
......@@ -212,7 +213,7 @@ hex_to_char(char in)
* less than 2*memsize characters in the source null-terminated string.
*/
int
hexstr_to_mem(unsigned char * dest, const unsigned char * source, int memsize)
hexstr_to_mem(unsigned char * dest, const char * source, int memsize)
{
int result = 1;
int i = 0;
......
......@@ -15,15 +15,15 @@ cleanup_checksum(void);
// Returns 1 if checksums matched, 0 if they failed to match.
// If the checksums fail to match, an error message is also printed.
int
verify_checksum(blockhdr_t *blockhdr, const char *bodybufp);
verify_checksum(blockhdr_t *blockhdr, const unsigned char *bodybufp);
int
encrypt_readkey(char *keyfile, unsigned char *keybuf, int buflen);
void
mem_to_hexstr(unsigned char *dest, const unsigned char *source, int memsize);
mem_to_hexstr(char *dest, const unsigned char *source, int memsize);
int
hexstr_to_mem(unsigned char *dest, const unsigned char *source, int memsize);
hexstr_to_mem(unsigned char *dest, const char *source, int memsize);
#endif
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2005, 2006 University of Utah and the Flux Group.
* Copyright (c) 2005-2010 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -412,7 +412,7 @@ hashmap_compute_delta(struct range *curranges, char *hfile, int infd,
uint32_t gapstart, gapsize, lastdrangeend = 0;
unsigned int hashlen;
unsigned char *(*hashfunc)(const unsigned char *,
unsigned long, unsigned char *);
size_t, unsigned char *);
struct range dummy_head, *range_tail;
struct hashregion *hreg, *ereg;
char *hashstr;
......
......@@ -303,7 +303,7 @@ dumpfile(char *name, int fd)
memcpy(imageid, hdr->imageid,
UUID_LENGTH);
if (detail > 0) {
uint8_t idbuf[UUID_LENGTH*2+1];
char idbuf[UUID_LENGTH*2+1];
mem_to_hexstr(idbuf,
hdr->imageid,
UUID_LENGTH);
......@@ -737,7 +737,7 @@ dumpchunk(char *name, char *buf, int chunkno, int checkindex)
* Checksum this image. Assumes SHA1, because we check for this above.
*/
if (checksums && hdr->checksumtype != CSUM_NONE) {
if (!verify_checksum(hdr, buf)) {
if (!verify_checksum(hdr, (unsigned char *)buf)) {
printf("ERROR: chunk %d fails checksum!\n", chunkno);
return 1;
}
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2009 University of Utah and the Flux Group.
* Copyright (c) 2000-2010 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -523,7 +523,7 @@ checkhash(char *name, struct hashinfo *hinfo)
struct hashregion *reg;
int chunkno;
unsigned char hash[HASH_MAXSIZE];
unsigned char *(*hashfunc)(const unsigned char *, unsigned long,
unsigned char *(*hashfunc)(const unsigned char *, size_t,
unsigned char *);
char *hashstr;
readbuf_t *rbuf;
......@@ -863,7 +863,7 @@ hashchunk(int chunkno, char *chunkbufp, struct hashinfo **hinfop)
z_stream z;
int err, nreg;
unsigned char hash[HASH_MAXSIZE];
unsigned char *(*hashfunc)(const unsigned char *, unsigned long,
unsigned char *(*hashfunc)(const unsigned char *, size_t,
unsigned char *);
readbuf_t *rbuf;
int errors = 0;
......@@ -1101,7 +1101,7 @@ hashfilechunk(int chunkno, char *chunkbufp, int chunksize,
int resid;
uint32_t cursect = 0, nbytes;
unsigned char hash[HASH_MAXSIZE];
unsigned char *(*hashfunc)(const unsigned char *, unsigned long,
unsigned char *(*hashfunc)(const unsigned char *, size_t,
unsigned char *);
unsigned char *bufp = (unsigned char *)chunkbufp;
int errors = 0;
......
......@@ -106,7 +106,7 @@ struct blockhdr_V4 {
int32_t reloccount; /* number of reloc entries */
/* V4 follows */
uint32_t enc_cipher; /* Which cipher was used to encrypt */
int8_t enc_iv[ENC_MAX_KEYLEN];
uint8_t enc_iv[ENC_MAX_KEYLEN];
/* Initialization vector */
uint32_t checksumtype; /* Which checksum was used */
unsigned char checksum[SIG_MAX_KEYLEN];
......
......@@ -1184,7 +1184,7 @@ write_subblock(int chunkno, const char *chunkbufp)
#ifdef WITH_CRYPTO
/* returns the number of characters decrypted */
static int
decrypt_buffer(char * dest, const char * source, const blockhdr_t * header)
decrypt_buffer(unsigned char *dest, const unsigned char *source, const blockhdr_t *header)
{
/* init */
int update_count = 0;
......@@ -1329,7 +1329,8 @@ inflate_subblock(const char *chunkbufp)
*/
if (do_decrypt) {
((blockhdr_t *)blockhdr)->size
= decrypt_buffer(plaintext, chunkbufp,
= decrypt_buffer((unsigned char *)plaintext,
(unsigned char *)chunkbufp,
blockhdr);
chunkbufp = plaintext;
}
......
......@@ -15,6 +15,7 @@
#ifdef WITH_CRYPTO
#include <openssl/evp.h>
#include <openssl/sha.h>
#include <openssl/rsa.h>
#include <openssl/rand.h>
#ifdef SIGN_CHECKSUM
#include <openssl/err.h>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment