Changeset 426
- Timestamp:
- 12/04/06 12:42:06
- Files:
-
- openpgpsdk/trunk/configure (modified) (1 diff)
- openpgpsdk/trunk/doc/doxygen-user.cfg (modified) (2 diffs)
- openpgpsdk/trunk/include/openpgpsdk/accumulate.h (modified) (1 diff)
- openpgpsdk/trunk/src/advanced (added)
- openpgpsdk/trunk/src/advanced/Makefile.template (moved) (moved from openpgpsdk/trunk/src/Makefile.template) (3 diffs)
- openpgpsdk/trunk/src/advanced/adv_accumulate.c (moved) (moved from openpgpsdk/trunk/src/accumulate.c)
- openpgpsdk/trunk/src/advanced/adv_armour.c (moved) (moved from openpgpsdk/trunk/src/armour.c)
- openpgpsdk/trunk/src/advanced/adv_compress.c (moved) (moved from openpgpsdk/trunk/src/compress.c)
- openpgpsdk/trunk/src/advanced/adv_create.c (moved) (moved from openpgpsdk/trunk/src/create.c)
- openpgpsdk/trunk/src/advanced/adv_crypto.c (moved) (moved from openpgpsdk/trunk/src/crypto.c)
- openpgpsdk/trunk/src/advanced/adv_errors.c (moved) (moved from openpgpsdk/trunk/src/errors.c)
- openpgpsdk/trunk/src/advanced/adv_fingerprint.c (moved) (moved from openpgpsdk/trunk/src/fingerprint.c)
- openpgpsdk/trunk/src/advanced/adv_hash.c (moved) (moved from openpgpsdk/trunk/src/hash.c)
- openpgpsdk/trunk/src/advanced/adv_keyring.c (moved) (moved from openpgpsdk/trunk/src/keyring.c) (3 diffs)
- openpgpsdk/trunk/src/advanced/adv_lists.c (moved) (moved from openpgpsdk/trunk/src/lists.c)
- openpgpsdk/trunk/src/advanced/adv_memory.c (moved) (moved from openpgpsdk/trunk/src/memory.c)
- openpgpsdk/trunk/src/advanced/adv_openssl_crypto.c (moved) (moved from openpgpsdk/trunk/src/openssl_crypto.c)
- openpgpsdk/trunk/src/advanced/adv_packet-parse.c (moved) (moved from openpgpsdk/trunk/src/packet-parse.c)
- openpgpsdk/trunk/src/advanced/adv_packet-show.c (moved) (moved from openpgpsdk/trunk/src/packet-show.c)
- openpgpsdk/trunk/src/advanced/adv_signature.c (moved) (moved from openpgpsdk/trunk/src/signature.c)
- openpgpsdk/trunk/src/advanced/adv_symmetric.c (moved) (moved from openpgpsdk/trunk/src/symmetric.c)
- openpgpsdk/trunk/src/advanced/adv_util.c (moved) (moved from openpgpsdk/trunk/src/util.c)
- openpgpsdk/trunk/src/advanced/adv_validate.c (moved) (moved from openpgpsdk/trunk/src/validate.c)
- openpgpsdk/trunk/src/advanced/keyring_local.h (moved) (moved from openpgpsdk/trunk/src/keyring_local.h)
- openpgpsdk/trunk/src/advanced/parse_local.h (moved) (moved from openpgpsdk/trunk/src/parse_local.h)
- openpgpsdk/trunk/src/doxygen.c (modified) (1 diff)
- openpgpsdk/trunk/src/standard (added)
- openpgpsdk/trunk/src/standard/Makefile.template (added)
- openpgpsdk/trunk/src/standard/std_keyring.c (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openpgpsdk/trunk/configure
r402 r426 127 127 128 128 129 create('src/.depend'); 129 create('src/advanced/.depend'); 130 create('src/standard/.depend'); 130 131 create('examples/.depend'); 131 132 132 133 fileSubst('src/Makefile','#',''); 134 fileSubst('src/advanced/Makefile','#',''); 135 fileSubst('src/standard/Makefile','#',''); 133 136 fileSubst('examples/Makefile','#',''); 134 137 fileSubst('util/Makefile.oink','#',''); openpgpsdk/trunk/doc/doxygen-user.cfg
r278 r426 463 463 # If left blank NO is used. 464 464 465 RECURSIVE = NO465 RECURSIVE = YES 466 466 467 467 # The EXCLUDE tag can be used to specify files and/or directories that should … … 701 701 # probably better off using the HTML help feature. 702 702 703 GENERATE_TREEVIEW = NO703 GENERATE_TREEVIEW = YES 704 704 705 705 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be openpgpsdk/trunk/include/openpgpsdk/accumulate.h
r422 r426 2 2 */ 3 3 4 #ifndef OPS_ACCUMULATE_H 5 #define OPS_ACCUMULATE_H 6 #endif 7 4 8 #include "keyring.h" 9 #include "packet-parse.h" 5 10 6 11 int ops_parse_and_accumulate(ops_keyring_t *keyring, openpgpsdk/trunk/src/advanced/Makefile.template
r425 r426 3 3 CC=%CC% 4 4 5 CFLAGS=$(DM_FLAGS) -I../ include %INCLUDES% %CFLAGS% -fPIC5 CFLAGS=$(DM_FLAGS) -I../..//include %INCLUDES% %CFLAGS% -fPIC 6 6 LDFLAGS=-g 7 7 LIBS=libops.a -lcrypto -lz $(DM_LIB) 8 8 9 all: Makefile headers .depend libops.a9 all: Makefile headers .depend ../libops.a 10 10 11 LIBOBJS = packet-parse.o util.o openssl_crypto.o accumulate.o \ 12 memory.o fingerprint.o hash.o keyring.o signature.o compress.o \ 13 packet-show.o create.o validate.o lists.o armour.o errors.o \ 14 symmetric.o crypto.o 11 LIBOBJS = adv_packet-parse.o adv_util.o adv_openssl_crypto.o adv_accumulate.o \ 12 adv_memory.o adv_fingerprint.o adv_hash.o adv_keyring.o \ 13 adv_signature.o adv_compress.o adv_packet-show.o adv_create.o \ 14 adv_validate.o adv_lists.o adv_armour.o adv_errors.o \ 15 adv_symmetric.o adv_crypto.o 15 16 16 17 headers: 17 cd ../ include/openpgpsdk && make headers18 cd ../../include/openpgpsdk && make headers 18 19 19 libops.a: $(LIBOBJS)20 ar rc libops.a $(LIBOBJS)20 ../libops.a: $(LIBOBJS) 21 ar rc ../libops.a $(LIBOBJS) 21 22 22 23 tags: … … 26 27 clean: 27 28 rm -f packet-dump verify *.o *.i 28 rm -f libops.a TAGS29 rm -f ../libops.a TAGS 29 30 30 .depend: *.[ch] ../ include/openpgpsdk/*.h31 .depend: *.[ch] ../../include/openpgpsdk/*.h 31 32 $(CC) $(CFLAGS) -E -M *.c > .depend 32 33 … … 34 35 $(CC) $(CFLAGS) -E -M *.c > .depend 35 36 36 Makefile: Makefile.template ../ configure37 Makefile: Makefile.template ../../configure 37 38 echo Makefile is older than templates, rerun configure. 38 39 exit 1 openpgpsdk/trunk/src/advanced/adv_keyring.c
r425 r426 16 16 17 17 #include <openpgpsdk/final.h> 18 19 ops_key_data_t *20 ops_keyring_find_key_by_id(const ops_keyring_t *keyring,21 const unsigned char keyid[OPS_KEY_ID_SIZE])22 {23 int n;24 25 for(n=0 ; n < keyring->nkeys ; ++n)26 if(!memcmp(keyring->keys[n].keyid,keyid,OPS_KEY_ID_SIZE))27 return &keyring->keys[n];28 29 return NULL;30 }31 32 unsigned char *33 ops_keyring_find_keyid_by_userid(const ops_keyring_t *keyring,34 const char *userid)35 {36 int n;37 unsigned int i;38 39 for(n=0 ; n < keyring->nkeys ; ++n)40 for(i=0; i<keyring->keys[n].nuids; n++)41 {42 printf("[%d][%d] userid %s\n",43 n,i,44 keyring->keys[n].uids[i].user_id);45 if(!strcmp((char *)keyring->keys[n].uids[i].user_id,userid))46 return &keyring->keys[n].keyid[0];47 }48 49 printf("end: n=%d,i=%d\n",n,i);50 return NULL;51 }52 18 53 19 void ops_key_data_free(ops_key_data_t *key) … … 71 37 } 72 38 73 /**74 * \ingroup Memory75 *76 * ops_keyring_free() frees the memory used in one ops_keyring_t structure77 * \param keyring Keyring to be freed.78 */79 void ops_keyring_free(ops_keyring_t *keyring)80 {81 int n;82 83 for(n=0 ; n < keyring->nkeys ; ++n)84 ops_key_data_free(&keyring->keys[n]);85 free(keyring->keys);86 keyring->keys=NULL;87 }88 89 39 const ops_public_key_t * 90 40 ops_get_public_key_from_data(const ops_key_data_t *data) … … 104 54 return NULL; 105 55 return &data->key.skey; 106 }107 108 static ops_parse_cb_return_t109 cb_keyring_read(const ops_parser_content_t *content_,110 ops_parse_cb_info_t *cbinfo)111 {112 // const ops_parser_content_union_t *content=&content_->content;113 // char buffer[1024];114 // size_t n;115 116 OPS_USED(cbinfo);117 118 switch(content_->tag)119 {120 case OPS_PARSER_PTAG:121 case OPS_PTAG_CT_ENCRYPTED_SECRET_KEY: // we get these because we didn't prompt122 case OPS_PTAG_CT_SIGNATURE_HEADER:123 case OPS_PTAG_CT_SIGNATURE_FOOTER:124 case OPS_PTAG_CT_SIGNATURE:125 case OPS_PTAG_CT_TRUST:126 case OPS_PARSER_ERRCODE:127 break;128 129 case OPS_PARSER_CMD_GET_SK_PASSPHRASE:130 // we don't want to prompt when reading the keyring131 break;132 133 default:134 fprintf(stderr,"Unexpected packet tag=%d (0x%x)\n",content_->tag,135 content_->tag);136 assert(0);137 exit(1);138 }139 140 return OPS_RELEASE_MEMORY;141 }142 143 /* Read a keyring from a file (either public or secret) */144 void ops_keyring_read(ops_keyring_t *keyring,const char *file)145 {146 ops_parse_info_t *pinfo;147 int fd;148 149 memset(keyring,'\0',sizeof *keyring);150 151 pinfo=ops_parse_info_new();152 153 fd=open(file,O_RDONLY);154 if(fd < 0)155 {156 perror(file);157 exit(1);158 }159 160 ops_reader_set_fd(pinfo,fd);161 162 ops_parse_cb_set(pinfo,cb_keyring_read,NULL);163 164 ops_parse_and_accumulate(keyring,pinfo);165 166 close(fd);167 168 ops_parse_info_delete(pinfo);169 56 } 170 57 openpgpsdk/trunk/src/doxygen.c
r236 r426 1 /*! \mainpage Documentation 2 * 3 * The OpenPGP::SDK library has 2 APIs, which can be used interchangeably by a developer. 4 5 \section section_std_api The Standard API 6 7 The Standard API provides easy access to common crypto tasks: Examples are: 8 9 - "find the key in the keyring corresponding to this id" 10 - "sign this text with that key". 11 12 It is built on functions offered by the Advanced API. 13 14 Developers should initially consider using the Standard API, unless they need the additional control available in the Advanced API. 15 16 - \ref StandardAPI : follow this link for more details 17 18 \section section_adv_api The Advanced API 19 20 The Advanced API offers detailed control over all aspects of the SDK. 21 22 - \ref AdvancedAPI : follow this link for more details 23 24 \section section_examples Examples 25 26 The <code>examples</code> directory included in the distribution provides 27 various standalone applications which demonstrate usage of the library. 28 29 - \subpage page_examples : follow this link for more details 30 31 \section section_installation Installation 32 33 - \subpage page_installation : follow this link for installation instructions 34 35 \page page_examples Examples 36 37 TBD 38 39 \page page_installation Installation 40 41 TBD 42 43 /** @defgroup StandardAPI Standard API 44 This API provides basic high-level functionality, which should be 45 suitable for most users. 46 47 If you want more fine-grained control, consider using the Advanced API. 48 */ 1 49 2 50 /** @defgroup PublicAPI Public API
