Changeset 454
- Timestamp:
- 04/08/07 14:59:42
- Files:
-
- openpgpsdk/trunk/examples/verify.c (modified) (3 diffs)
- openpgpsdk/trunk/include/openpgpsdk/validate.h (modified) (1 diff)
- openpgpsdk/trunk/src/advanced/adv_validate.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openpgpsdk/trunk/examples/verify.c
r452 r454 17 17 const char *target; 18 18 int fd; 19 ops_validate_result_t result; 19 20 20 21 if(argc != 2) … … 50 51 ops_dump_keyring(&keyring); 51 52 52 ops_validate_all_signatures(& keyring);53 ops_validate_all_signatures(&result,&keyring); 53 54 54 55 ops_keyring_free(&keyring); … … 56 57 ops_finish(); 57 58 59 printf("valid signatures = %d\n",result.valid_count); 60 printf("invalid signatures = %d\n",result.invalid_count); 61 printf("unknown signer = %d\n",result.unknown_signer_count); 62 63 if(result.invalid_count) 64 return 1; 65 58 66 return 0; 59 67 } openpgpsdk/trunk/include/openpgpsdk/validate.h
r336 r454 1 void ops_validate_all_signatures(const ops_keyring_t *ring); 1 typedef struct 2 { 3 unsigned int valid_count; 4 unsigned int invalid_count; 5 unsigned int unknown_signer_count; 6 } ops_validate_result_t; 7 8 void ops_validate_all_signatures(ops_validate_result_t *result, 9 const ops_keyring_t *ring); 2 10 void ops_key_data_reader_set(ops_parse_info_t *pinfo, 3 11 const ops_key_data_t *key); openpgpsdk/trunk/src/advanced/adv_validate.c
r452 r454 24 24 const ops_keyring_t *keyring; 25 25 validate_reader_arg_t *rarg; 26 ops_validate_result_t *result; 26 27 } validate_cb_arg_t; 27 28 … … 94 95 { 95 96 printf(" UNKNOWN SIGNER\n"); 97 ++arg->result->unknown_signer_count; 96 98 break; 97 99 } … … 129 131 } 130 132 if(valid) 133 { 131 134 printf(" validated\n"); 135 ++arg->result->valid_count; 136 } 132 137 else 138 { 133 139 printf(" BAD SIGNATURE\n"); 140 ++arg->result->invalid_count; 141 } 134 142 break; 135 143 … … 155 163 } 156 164 157 static void validate_key_signatures( const ops_key_data_t *key,165 static void validate_key_signatures(ops_validate_result_t *result,const ops_key_data_t *key, 158 166 const ops_keyring_t *keyring) 159 167 { … … 162 170 163 171 memset(&carg,'\0',sizeof carg); 172 carg.result=result; 164 173 165 174 pinfo=ops_parse_info_new(); … … 181 190 } 182 191 183 void ops_validate_all_signatures(const ops_keyring_t *ring) 192 void ops_validate_all_signatures(ops_validate_result_t *result, 193 const ops_keyring_t *ring) 184 194 { 185 195 int n; 186 196 197 memset(result,'\0',sizeof *result); 187 198 for(n=0 ; n < ring->nkeys ; ++n) 188 validate_key_signatures( &ring->keys[n],ring);189 } 199 validate_key_signatures(result,&ring->keys[n],ring); 200 }
