Skip to content

Commit

Permalink
Fix gcc 4.6 warnings (one of which was an actual bug).
Browse files Browse the repository at this point in the history
git-svn-id: svn://openpgp.nominet.org.uk/openpgpsdk/trunk@705 228a932f-eeec-0310-9813-fb354622df21
  • Loading branch information
ben committed May 29, 2010
1 parent 7d14fdf commit 4af5c39
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 21 deletions.
3 changes: 2 additions & 1 deletion include/openpgpsdk/packet.h
Expand Up @@ -362,7 +362,8 @@ typedef struct
ops_public_key_t public_key;
ops_s2k_usage_t s2k_usage;
ops_s2k_specifier_t s2k_specifier;
ops_public_key_algorithm_t algorithm;
ops_symmetric_algorithm_t algorithm; // the algorithm used to encrypt
// the key
ops_hash_algorithm_t hash_algorithm;
unsigned char salt[OPS_SALT_SIZE];
unsigned octet_count;
Expand Down
4 changes: 0 additions & 4 deletions src/app/openpgp.c
Expand Up @@ -151,9 +151,7 @@ int main(int argc, char **argv)
int got_homedir=0;
int got_keyring=0;
int got_userid=0;
int got_passphrase=0;
int got_filename=0;
int got_numbits=0;
int numbits=DEFAULT_NUMBITS;
char outputfilename[MAXBUF+1]="";
ops_keyring_t* myring=NULL;
Expand Down Expand Up @@ -253,7 +251,6 @@ int main(int argc, char **argv)
case PASSPHRASE:
assert(optarg);
snprintf(opt_passphrase,MAXBUF,"%s",optarg);
got_passphrase=1;
break;

case FILENAME:
Expand Down Expand Up @@ -281,7 +278,6 @@ int main(int argc, char **argv)
case NUMBITS:
assert(optarg);
numbits=atoi(optarg);
got_numbits=1;
break;

default:
Expand Down
6 changes: 1 addition & 5 deletions src/lib/packet-parse.c
Expand Up @@ -2161,7 +2161,6 @@ static int parse_secret_key(ops_region_t *region,ops_parse_info_t *pinfo)
int ret=1;
ops_region_t encregion;
ops_region_t *saved_region=NULL;
size_t checksum_length=2;
ops_hash_t checkhash;
int blocksize;
ops_boolean_t crypted;
Expand All @@ -2186,8 +2185,6 @@ static int parse_secret_key(ops_region_t *region,ops_parse_info_t *pinfo)
if(!limited_read(c,1,region,pinfo))
return 0;
C.secret_key.s2k_usage=c[0];
if(C.secret_key.s2k_usage == OPS_S2KU_ENCRYPTED_AND_HASHED)
checksum_length=20;

if(C.secret_key.s2k_usage == OPS_S2KU_ENCRYPTED
|| C.secret_key.s2k_usage == OPS_S2KU_ENCRYPTED_AND_HASHED)
Expand Down Expand Up @@ -3054,8 +3051,7 @@ int ops_parse(ops_parse_info_t *pinfo)

int ops_parse_and_print_errors(ops_parse_info_t *pinfo)
{
int r;
r=ops_parse(pinfo);
ops_parse(pinfo);
ops_print_errors(pinfo->errors);
return pinfo->errors ? 0 : 1;
}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/signature.c
Expand Up @@ -107,11 +107,10 @@ ops_boolean_t encode_hash_buf(const unsigned char *M, size_t mLen,
// implementation of EMSA-PKCS1-v1_5, as defined in OpenPGP RFC

unsigned i;

int n=0;
int n;
ops_hash_t hash;
int hash_sz=0;
int encoded_hash_sz=0;
// int encoded_hash_sz=0;
int prefix_sz=0;
unsigned padding_sz=0;
unsigned encoded_msg_sz=0;
Expand All @@ -135,7 +134,7 @@ ops_boolean_t encode_hash_buf(const unsigned char *M, size_t mLen,
prefix=prefix_sha1;
prefix_sz=sizeof prefix_sha1;
hash_sz=OPS_SHA1_HASH_SIZE;
encoded_hash_sz=hash_sz+prefix_sz;
// encoded_hash_sz=hash_sz+prefix_sz;
// \todo why is Ben using a PS size of 90 in rsa_sign?
// (keysize-hashsize-1-2)
padding_sz=90;
Expand Down Expand Up @@ -165,6 +164,7 @@ ops_boolean_t encode_hash_buf(const unsigned char *M, size_t mLen,
// finally, write out hashed result

n=hash.finish(&hash, &EM[i]);
assert(n == hash_sz);

encoded_msg_sz=i+hash_sz-1;

Expand Down
6 changes: 3 additions & 3 deletions tests/test_crypt_mpi.c
Expand Up @@ -60,16 +60,16 @@ void test_crypt_mpi(void)
unsigned char in[BSZ];
unsigned char out[BSZ];

ops_boolean_t rtn;

ops_pk_session_key_t *encrypted_pk_session_key=NULL;

encrypted_pk_session_key=ops_create_pk_session_key(pubkey);

// the encrypted_mpi is now in session_key->parameters.rsa.encrypted_m

// decrypt it
rtn=ops_decrypt_and_unencode_mpi(out,BSZ, encrypted_pk_session_key->parameters.rsa.encrypted_m, &seckey->key.skey);
ops_decrypt_and_unencode_mpi(out, BSZ,
encrypted_pk_session_key->parameters.rsa.encrypted_m,
&seckey->key.skey);

// is it the same?
CU_ASSERT(memcmp((char *)in,(char *)out,sizeof(in))==0);
Expand Down
6 changes: 2 additions & 4 deletions tests/test_rsa_keys.c
Expand Up @@ -98,8 +98,6 @@ static void verify_keypair(ops_boolean_t armoured)
ops_validate_result_t* result=NULL;
ops_keyring_t pub_keyring;
ops_keyring_t sec_keyring;
const ops_public_key_t* pub_key=NULL;
const ops_secret_key_t* sec_key=NULL;
static const unsigned char pp[]="hello";
char filename[MAXBUF+1];
int fd=0;
Expand All @@ -118,8 +116,8 @@ static void verify_keypair(ops_boolean_t armoured)

keydata=ops_rsa_create_selfsigned_keypair(1024, 65537, &uid);
CU_ASSERT(keydata != NULL);
pub_key=ops_get_public_key_from_data(keydata);
sec_key=ops_get_secret_key_from_data(keydata);
ops_get_public_key_from_data(keydata);
ops_get_secret_key_from_data(keydata);
keyid=ops_get_key_id(keydata);

/*
Expand Down

0 comments on commit 4af5c39

Please sign in to comment.