Changeset 48
- Timestamp:
- 04/05/05 12:46:02
- Files:
-
- openpgpsdk/trunk/src/Makefile (modified) (2 diffs)
- openpgpsdk/trunk/src/accumulate.c (modified) (2 diffs)
- openpgpsdk/trunk/src/crypto.h (modified) (1 diff)
- openpgpsdk/trunk/src/fingerprint.c (modified) (1 diff)
- openpgpsdk/trunk/src/keyring.c (modified) (2 diffs)
- openpgpsdk/trunk/src/keyring.h (modified) (1 diff)
- openpgpsdk/trunk/src/memory.c (modified) (1 diff)
- openpgpsdk/trunk/src/openssl_crypto.c (modified) (2 diffs)
- openpgpsdk/trunk/src/packet-parse.c (modified) (3 diffs)
- openpgpsdk/trunk/src/packet.h (modified) (2 diffs)
- openpgpsdk/trunk/src/util.c (modified) (2 diffs)
- openpgpsdk/trunk/src/validate.c (modified) (1 diff)
- openpgpsdk/trunk/src/verify.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openpgpsdk/trunk/src/Makefile
r44 r48 1 1 # $Id$ 2 2 3 CFLAGS=-Wall -Werror -g 3 DM_FLAGS=-DDMALLOC -I/usr/local/include 4 DM_LIB=/usr/local/lib/libdmalloc.a 5 6 CFLAGS=-Wall -Werror -g $(DM_FLAGS) 4 7 LDFLAGS=-g 5 8 … … 11 14 12 15 packet-dump: packet-dump.o libops.a 13 $(CC) $(LDFLAGS) -o packet-dump packet-dump.o libops.a -lcrypto 16 $(CC) $(LDFLAGS) -o packet-dump packet-dump.o libops.a -lcrypto \ 17 $(DM_LIB) 14 18 15 19 verify: verify.o libops.a 16 $(CC) $(LDFLAGS) -o verify verify.o libops.a -lcrypto 20 $(CC) $(LDFLAGS) -o verify verify.o libops.a -lcrypto $(DM_LIB) 21 22 tags: 23 rm -f TAGS 24 find . -name '*.[ch]' | xargs etags -a 25 17 26 clean: 18 27 rm -f packet-dump packet-dump.o packet-parse.o .depend openpgpsdk/trunk/src/accumulate.c
r47 r48 153 153 154 154 case OPS_PTAG_CT_PUBLIC_SUBKEY: 155 if(arg->subkey.version) 156 ops_public_key_free(&arg->subkey); 155 157 arg->subkey=content->public_key; 156 158 return OPS_KEEP_MEMORY; … … 238 240 239 241 ops_public_key_free(&arg.pkey); 242 if(arg.subkey.version) 243 ops_public_key_free(&arg.subkey); 240 244 ops_user_id_free(&arg.user_id); 241 245 } openpgpsdk/trunk/src/crypto.h
r46 r48 19 19 }; 20 20 21 void ops_crypto_init(void); 22 void ops_crypto_finish(void); 21 23 void ops_hash_md5(ops_hash_t *hash); 22 24 void ops_hash_sha1(ops_hash_t *hash); openpgpsdk/trunk/src/fingerprint.c
r46 r48 4 4 #include "build.h" 5 5 #include <assert.h> 6 7 #ifdef DMALLOC 8 # include <dmalloc.h> 9 #endif 6 10 7 11 void ops_fingerprint(ops_fingerprint_t *fp,const ops_public_key_t *key) openpgpsdk/trunk/src/keyring.c
r44 r48 1 1 #include "keyring.h" 2 2 #include "keyring_local.h" 3 #include <stdlib.h> 4 5 #ifdef DMALLOC 6 # include <dmalloc.h> 7 #endif 3 8 4 9 ops_key_data_t * … … 14 19 return NULL; 15 20 } 21 22 void ops_key_data_free(ops_key_data_t *key) 23 { 24 int n; 25 26 for(n=0 ; n < key->nuids ; ++n) 27 ops_user_id_free(&key->uids[n]); 28 free(key->uids); 29 key->uids=NULL; 30 31 for(n=0 ; n < key->npackets ; ++n) 32 ops_packet_free(&key->packets[n]); 33 free(key->packets); 34 key->packets=NULL; 35 36 ops_public_key_free(&key->pkey); 37 } 38 39 void ops_keyring_free(ops_keyring_t *keyring) 40 { 41 int n; 42 43 for(n=0 ; n < keyring->nkeys ; ++n) 44 ops_key_data_free(&keyring->keys[n]); 45 free(keyring->keys); 46 keyring->keys=NULL; 47 } openpgpsdk/trunk/src/keyring.h
r44 r48 13 13 ops_keyring_find_key_by_id(const ops_keyring_t *keyring, 14 14 const unsigned char keyid[OPS_KEY_ID_SIZE]); 15 void ops_key_data_free(ops_key_data_t *key); 16 void ops_keyring_free(ops_keyring_t *keyring); openpgpsdk/trunk/src/memory.c
r40 r48 2 2 #include <stdlib.h> 3 3 #include <assert.h> 4 5 #ifdef DMALLOC 6 # include <dmalloc.h> 7 #endif 4 8 5 9 void ops_memory_init(ops_memory_t *mem,size_t initial_size) openpgpsdk/trunk/src/openssl_crypto.c
r46 r48 4 4 #include <openssl/dsa.h> 5 5 #include <openssl/rsa.h> 6 #include <openssl/err.h> 6 7 #include <assert.h> 7 8 #include <stdlib.h> 9 10 #ifdef DMALLOC 11 # include <dmalloc.h> 12 #endif 8 13 9 14 static void md5_init(ops_hash_t *hash) … … 109 114 return n; 110 115 } 116 117 void ops_crypto_init() 118 { 119 #ifdef DMALLOC 120 CRYPTO_malloc_debug_init(); 121 CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL); 122 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); 123 #endif 124 } 125 126 void ops_crypto_finish() 127 { 128 CRYPTO_cleanup_all_ex_data(); 129 ERR_remove_state(0); 130 #ifdef DMALLOC 131 CRYPTO_mem_leaks_fp(stderr); 132 #endif 133 } openpgpsdk/trunk/src/packet-parse.c
r44 r48 12 12 #include <stdlib.h> 13 13 #include <string.h> 14 15 #ifdef DMALLOC 16 # include <dmalloc.h> 17 #endif 14 18 15 19 typedef struct ops_region … … 321 325 } 322 326 327 void ops_packet_free(ops_packet_t *packet) 328 { 329 free(packet->raw); 330 packet->raw=NULL; 331 } 332 323 333 void ops_content_free_inner(ops_parser_content_t *c) 324 334 { … … 345 355 346 356 case OPS_PARSER_PACKET_END: 347 free(c->content.packet.raw); 348 c->content.packet.raw=NULL; 357 ops_packet_free(&c->content.packet); 358 break; 359 360 case OPS_PARSER_ERROR: 349 361 break; 350 362 openpgpsdk/trunk/src/packet.h
r44 r48 406 406 } ops_fingerprint_t; 407 407 408 void ops_init(void); 409 void ops_finish(void); 408 410 void ops_keyid(unsigned char keyid[OPS_KEY_ID_SIZE], 409 411 const ops_public_key_t *key); … … 412 414 void ops_user_id_free(ops_user_id_t *id); 413 415 void ops_signature_free(ops_signature_t *sig); 416 void ops_packet_free(ops_packet_t *packet); 414 417 415 418 /* vim:set textwidth=120: */ openpgpsdk/trunk/src/util.c
r46 r48 1 1 #include "util.h" 2 #include "crypto.h" 2 3 #include <stdio.h> 3 4 #include <assert.h> … … 8 9 printf("%02X",*src++); 9 10 } 11 12 void ops_init(void) 13 { 14 ops_crypto_init(); 15 } 16 17 void ops_finish(void) 18 { 19 ops_crypto_finish(); 20 } openpgpsdk/trunk/src/validate.c
r40 r48 5 5 #include <assert.h> 6 6 #include <openssl/md5.h> 7 8 #ifdef DMALLOC 9 # include <dmalloc.h> 10 #endif 7 11 8 12 typedef struct openpgpsdk/trunk/src/verify.c
r44 r48 27 27 ops_keyring_t keyring; 28 28 29 ops_init(); 30 29 31 memset(&keyring,'\0',sizeof keyring); 30 32 ops_parse_options_init(&opt); … … 35 37 ops_parse_and_accumulate(&keyring,&opt); 36 38 39 ops_keyring_free(&keyring); 40 41 ops_finish(); 42 37 43 return 0; 38 44 }
