Changeset 426

Show
Ignore:
Timestamp:
12/04/06 12:42:06
Author:
rachel
Message:

Split src into Standard and Advanced APIs.
Move keyring standard functions into Standard API.
Document keyring Standard API functions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openpgpsdk/trunk/configure

    r402 r426  
    127127 
    128128 
    129 create('src/.depend'); 
     129create('src/advanced/.depend'); 
     130create('src/standard/.depend'); 
    130131create('examples/.depend'); 
    131132 
    132133fileSubst('src/Makefile','#',''); 
     134fileSubst('src/advanced/Makefile','#',''); 
     135fileSubst('src/standard/Makefile','#',''); 
    133136fileSubst('examples/Makefile','#',''); 
    134137fileSubst('util/Makefile.oink','#',''); 
  • openpgpsdk/trunk/doc/doxygen-user.cfg

    r278 r426  
    463463# If left blank NO is used. 
    464464 
    465 RECURSIVE              = NO 
     465RECURSIVE              = YES 
    466466 
    467467# The EXCLUDE tag can be used to specify files and/or directories that should  
     
    701701# probably better off using the HTML help feature. 
    702702 
    703 GENERATE_TREEVIEW      = NO 
     703GENERATE_TREEVIEW      = YES 
    704704 
    705705# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be  
  • openpgpsdk/trunk/include/openpgpsdk/accumulate.h

    r422 r426  
    22 */ 
    33 
     4#ifndef OPS_ACCUMULATE_H 
     5#define OPS_ACCUMULATE_H 
     6#endif 
     7 
    48#include "keyring.h" 
     9#include "packet-parse.h" 
    510 
    611int ops_parse_and_accumulate(ops_keyring_t *keyring, 
  • openpgpsdk/trunk/src/advanced/Makefile.template

    r425 r426  
    33CC=%CC% 
    44 
    5 CFLAGS=$(DM_FLAGS) -I../include %INCLUDES% %CFLAGS% -fPIC 
     5CFLAGS=$(DM_FLAGS) -I../..//include %INCLUDES% %CFLAGS% -fPIC 
    66LDFLAGS=-g 
    77LIBS=libops.a -lcrypto -lz $(DM_LIB) 
    88 
    9 all: Makefile headers .depend libops.a 
     9all: Makefile headers .depend ../libops.a 
    1010 
    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 
     11LIBOBJS = 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 
    1516 
    1617headers: 
    17         cd ../include/openpgpsdk && make headers 
     18        cd ../../include/openpgpsdk && make headers 
    1819 
    19 libops.a: $(LIBOBJS) 
    20         ar rc libops.a $(LIBOBJS) 
     20../libops.a: $(LIBOBJS) 
     21        ar rc ../libops.a $(LIBOBJS) 
    2122 
    2223tags: 
     
    2627clean: 
    2728        rm -f packet-dump verify *.o *.i 
    28         rm -f libops.a TAGS 
     29        rm -f ../libops.a TAGS 
    2930 
    30 .depend: *.[ch] ../include/openpgpsdk/*.h 
     31.depend: *.[ch] ../../include/openpgpsdk/*.h 
    3132        $(CC) $(CFLAGS) -E -M *.c > .depend 
    3233 
     
    3435        $(CC) $(CFLAGS) -E -M *.c > .depend 
    3536 
    36 Makefile: Makefile.template ../configure 
     37Makefile: Makefile.template ../../configure 
    3738        echo Makefile is older than templates, rerun configure. 
    3839        exit 1 
  • openpgpsdk/trunk/src/advanced/adv_keyring.c

    r425 r426  
    1616 
    1717#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     } 
    5218 
    5319void ops_key_data_free(ops_key_data_t *key) 
     
    7137    } 
    7238 
    73 /** 
    74  * \ingroup Memory 
    75  * 
    76  * ops_keyring_free() frees the memory used in one ops_keyring_t structure 
    77  * \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  
    8939const ops_public_key_t * 
    9040ops_get_public_key_from_data(const ops_key_data_t *data) 
     
    10454        return NULL; 
    10555    return &data->key.skey; 
    106     } 
    107  
    108 static ops_parse_cb_return_t 
    109 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 prompt 
    122     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 keyring 
    131         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); 
    16956    } 
    17057 
  • 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 
     7The 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 
     12It is built on functions offered by the Advanced API. 
     13 
     14Developers 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 
     20The 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 
     26The <code>examples</code> directory included in the distribution provides 
     27various 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 
     37TBD 
     38 
     39\page page_installation Installation 
     40 
     41TBD 
     42 
     43/** @defgroup StandardAPI Standard API 
     44This API provides basic high-level functionality, which should be 
     45suitable for most users. 
     46 
     47If you want more fine-grained control, consider using the Advanced API. 
     48*/ 
    149 
    250/** @defgroup PublicAPI Public API