Changeset 314

Show
Ignore:
Timestamp:
11/29/05 16:06:23
Author:
ben
Message:

Inline signing. Not 100% RFC compliant yet, but seems to work. References #26.

Files:

Legend:

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

    • Property svn:ignore changed from create-key create-signed-key verify packet-dump .depend Makefile to create-key create-signed-key verify packet-dump .depend Makefile sign-inline verify2 sign-detached dmalloc.log
  • openpgpsdk/trunk/examples/Makefile.template

    r307 r314  
    77LIBDEPS=common.o ../src/libops.a 
    88LIBS=$(LIBDEPS) %CRYPTO_LIBS% %ZLIB% $(DM_LIB) %LIBS% 
    9 EXES=packet-dump verify create-key create-signed-key verify2 sign-detached 
     9EXES=packet-dump verify create-key create-signed-key verify2 sign-detached \ 
     10     sign-inline 
    1011 
    1112all: Makefile .depend $(EXES) 
     
    3334sign-detached: sign-detached.o $(LIBDEPS) 
    3435        $(CC) $(LDFLAGS) -o sign-detached sign-detached.o $(LIBS) 
     36 
     37sign-inline: sign-inline.o $(LIBDEPS) 
     38        $(CC) $(LDFLAGS) -o sign-inline sign-inline.o $(LIBS) 
    3539 
    3640tags: 
     
    8286        ./sign-detached $(SCRATCH)/key.sec "Why a user ID?" SHA1 $(SCRATCH)/to-be-signed-detached $(SCRATCH)/to-be-signed-detached.sig 
    8387 
     88test-sign-inline: $(SCRATCH)/key.sec sign-inline 
     89        echo "Sign this!" > $(SCRATCH)/to-be-signed-inline 
     90        echo "- test dash-escaping" >> $(SCRATCH)/to-be-signed-inline 
     91        ./sign-inline $(SCRATCH)/key.sec "Why a user ID?" SHA1 $(SCRATCH)/to-be-signed-inline $(SCRATCH)/to-be-signed-inline.sig 
     92 
    8493include .depend 
  • openpgpsdk/trunk/examples/create-key.c

    r307 r314  
    2626 
    2727    info=ops_create_info_new(); 
    28     ops_create_info_set_writer_fd(info,1); 
     28    ops_writer_set_fd(info,1); 
    2929 
    3030    ops_write_rsa_public_key(time(NULL),n,e,info); 
  • openpgpsdk/trunk/examples/create-signed-key.c

    r308 r314  
    6363        exit(2); 
    6464        } 
    65     ops_create_info_set_writer_fd(info,fd); 
     65    ops_writer_set_fd(info,fd); 
    6666 
    6767    ops_write_struct_secret_key(&skey,info); 
    6868 
    69     ops_create_info_close_writer(info); 
     69    ops_writer_close(info); 
    7070 
    7171    close(fd); 
     
    7777        exit(2); 
    7878        } 
    79     ops_create_info_set_writer_fd(info,fd); 
     79    ops_writer_set_fd(info,fd); 
    8080 
    8181    ops_write_struct_public_key(&skey.public_key,info); 
  • openpgpsdk/trunk/include/openpgpsdk/armour.h

    r296 r314  
    11#include "packet-parse.h" 
     2#include "signature.h" 
    23 
    34void ops_reader_push_dearmour(ops_parse_info_t *parse_info); 
    45void ops_reader_pop_dearmour(ops_parse_info_t *parse_info); 
     6void ops_writer_push_dash_escaped(ops_create_info_t *info, 
     7                                  ops_create_signature_t *sig); 
     8void ops_writer_switch_to_signature(ops_create_info_t *info); 
     9 
  • openpgpsdk/trunk/include/openpgpsdk/create.h

    r307 r314  
    1111#include "errors.h" 
    1212 
    13 /** expected return values from the writer function 
    14  */ 
    15  
    16 enum ops_writer_ret_t 
    17     { 
    18     OPS_W_OK            =0, 
    19     OPS_W_ERROR         =1, 
    20     }; 
    21  
     13typedef struct ops_writer_info ops_writer_info_t; 
    2214/** 
    2315 * \ingroup Create 
    2416 * the writer function prototype 
    2517 */ 
    26 typedef ops_writer_ret_t ops_writer_t(const unsigned char *src, 
     18typedef ops_boolean_t ops_writer_t(const unsigned char *src, 
    2719                                      unsigned length, 
    28                                       ops_writer_flags_t flags, 
    2920                                      ops_error_t **errors, 
    30                                       void *arg); 
    31  
    32 typedef void ops_writer_destroyer_t(void *arg); 
    33  
    34 void ops_create_info_set_writer(ops_create_info_t *info, 
    35                                 ops_writer_t *writer, 
    36                                 ops_writer_destroyer_t *destroyer, 
    37                                 void *arg); 
     21                                      ops_writer_info_t *winfo); 
     22typedef ops_boolean_t ops_writer_finaliser_t(ops_error_t **errors, 
     23                                             ops_writer_info_t *winfo); 
     24typedef void ops_writer_destroyer_t(ops_writer_info_t *winfo); 
    3825 
    3926ops_create_info_t *ops_create_info_new(void); 
    4027void ops_create_info_delete(ops_create_info_t *info); 
    41 void ops_create_info_set_writer_fd(ops_create_info_t *info,int fd); 
    42 void ops_create_info_close_writer(ops_create_info_t *info); 
     28void *ops_writer_get_arg(ops_writer_info_t *winfo); 
     29ops_boolean_t ops_stacked_write(const void *src,unsigned length, 
     30                                ops_error_t **errors, 
     31                                ops_writer_info_t *winfo); 
     32 
     33void ops_writer_set(ops_create_info_t *info, 
     34                    ops_writer_t *writer, 
     35                    ops_writer_finaliser_t *finaliser, 
     36                    ops_writer_destroyer_t *destroyer, 
     37                    void *arg); 
     38void ops_writer_push(ops_create_info_t *info, 
     39                     ops_writer_t *writer, 
     40                     ops_writer_finaliser_t *finaliser, 
     41                     ops_writer_destroyer_t *destroyer, 
     42                     void *arg); 
     43void ops_writer_pop(ops_create_info_t *info); 
     44void ops_writer_generic_destroyer(ops_writer_info_t *winfo); 
     45 
     46void ops_writer_set_fd(ops_create_info_t *info,int fd); 
     47ops_boolean_t ops_writer_close(ops_create_info_t *info); 
    4348 
    4449ops_boolean_t ops_write(const void *src,unsigned length, 
  • openpgpsdk/trunk/include/openpgpsdk/crypto.h

    r304 r314  
    1919    { 
    2020    ops_hash_algorithm_t algorithm; 
     21    const char *name; 
    2122    ops_hash_init_t *init; 
    2223    ops_hash_add_t *add; 
     
    3132void ops_hash_any(ops_hash_t *hash,ops_hash_algorithm_t alg); 
    3233ops_hash_algorithm_t ops_hash_algorithm_from_text(const char *hash); 
     34const char *ops_text_from_hash(ops_hash_t *hash); 
    3335unsigned ops_hash_size(ops_hash_algorithm_t alg); 
    3436 
  • openpgpsdk/trunk/include/openpgpsdk/signature.h

    r307 r314  
    11/** \file 
    22 */ 
     3 
     4#ifndef OPS_SIGNATURE_H 
     5#define OPS_SIGNATURE_H 
    36 
    47#include "packet.h" 
     
    3740void ops_signature_add_data(ops_create_signature_t *sig,const void *buf, 
    3841                            size_t length); 
     42ops_hash_t *ops_signature_get_hash(ops_create_signature_t *sig); 
    3943void ops_signature_hashed_subpackets_end(ops_create_signature_t *sig); 
    4044void ops_write_signature(ops_create_signature_t *sig,ops_public_key_t *key, 
     
    4549void ops_signature_add_primary_user_id(ops_create_signature_t *sig, 
    4650                                       ops_boolean_t primary); 
     51 
     52#endif 
  • openpgpsdk/trunk/src/armour.c

    r307 r314  
    33#include <openpgpsdk/util.h> 
    44#include <openpgpsdk/crypto.h> 
     5#include <openpgpsdk/create.h> 
     6#include <openpgpsdk/signature.h> 
    57 
    68#include <string.h> 
     
    707709    free(arg); 
    708710    } 
     711 
     712typedef struct 
     713    { 
     714    ops_boolean_t seen_nl:1; 
     715    ops_boolean_t seen_cr:1; 
     716    ops_create_signature_t *sig; 
     717    } dash_escaped_arg_t; 
     718 
     719static ops_boolean_t dash_escaped_writer(const unsigned char *src, 
     720                                         unsigned length, 
     721                                         ops_error_t **errors, 
     722                                         ops_writer_info_t *winfo) 
     723    { 
     724    dash_escaped_arg_t *arg=ops_writer_get_arg(winfo); 
     725    unsigned n; 
     726 
     727    // XXX: make this efficient 
     728    for(n=0 ; n < length ; ++n) 
     729        { 
     730        if(arg->seen_nl) 
     731            { 
     732            if(src[n] == '-' && !ops_stacked_write("- ",2,errors,winfo)) 
     733                return ops_false; 
     734            arg->seen_nl=ops_false; 
     735            } 
     736        arg->seen_nl=src[n] == '\n'; 
     737        if(arg->seen_nl && !arg->seen_cr) 
     738            { 
     739            if(!ops_stacked_write("\r",1,errors,winfo)) 
     740                return ops_false; 
     741            ops_signature_add_data(arg->sig,"\r",1); 
     742            } 
     743        arg->seen_cr=src[n] == '\r'; 
     744        if(!ops_stacked_write(&src[n],1,errors,winfo)) 
     745            return ops_false; 
     746        ops_signature_add_data(arg->sig,&src[n],1); 
     747        } 
     748 
     749    return ops_true; 
     750    } 
     751 
     752void dash_escaped_destroyer(ops_writer_info_t *winfo) 
     753    { 
     754    dash_escaped_arg_t *arg=ops_writer_get_arg(winfo); 
     755 
     756    free(arg); 
     757    } 
     758 
     759// XXX: should return errors. 
     760void ops_writer_push_dash_escaped(ops_create_info_t *info, 
     761                                  ops_create_signature_t *sig) 
     762    { 
     763    static char header[]="-----BEGIN PGP SIGNED MESSAGE-----\r\nHash: "; 
     764    const char *hash=ops_text_from_hash(ops_signature_get_hash(sig)); 
     765    dash_escaped_arg_t *arg=ops_mallocz(sizeof *arg); 
     766 
     767    ops_write(header,sizeof header-1,info); 
     768    ops_write(hash,strlen(hash),info); 
     769    ops_write("\r\n\r\n",4,info); 
     770    arg->seen_nl=ops_true; 
     771    arg->sig=sig; 
     772    ops_writer_push(info,dash_escaped_writer,NULL,dash_escaped_destroyer,arg); 
     773    } 
     774 
     775typedef struct 
     776    { 
     777    unsigned pos; 
     778    unsigned char t; 
     779    } base64_arg_t; 
     780 
     781static char b64map[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" 
     782"0123456789+/"; 
     783 
     784static ops_boolean_t base64_writer(const unsigned char *src, 
     785                                      unsigned length, 
     786                                      ops_error_t **errors, 
     787                                      ops_writer_info_t *winfo) 
     788    { 
     789    base64_arg_t *arg=ops_writer_get_arg(winfo); 
     790    unsigned n; 
     791 
     792    for(n=0 ; n < length ; ) 
     793        { 
     794        if(arg->pos == 0) 
     795            { 
     796            /* XXXXXX00 00000000 00000000 */ 
     797            if(!ops_stacked_write(&b64map[src[n] >> 2],1,errors,winfo)) 
     798                return ops_false; 
     799 
     800            /* 000000XX xxxx0000 00000000 */ 
     801            arg->t=(src[n++]&3) << 4; 
     802            arg->pos=1; 
     803            } 
     804        else if(arg->pos == 1) 
     805            { 
     806            /* 000000xx XXXX0000 00000000 */ 
     807            arg->t+=src[n] >> 4; 
     808            if(!ops_stacked_write(&b64map[arg->t],1,errors,winfo)) 
     809                return ops_false; 
     810 
     811            /* 00000000 0000XXXX xx000000 */ 
     812            arg->t=(src[n++]&0xf) << 2; 
     813            arg->pos=2; 
     814            } 
     815        else if(arg->pos == 2) 
     816            { 
     817            /* 00000000 0000xxxx XX000000 */ 
     818            arg->t+=src[n] >> 6; 
     819            if(!ops_stacked_write(&b64map[arg->t],1,errors,winfo)) 
     820                return ops_false; 
     821 
     822            /* 00000000 00000000 00XXXXXX */ 
     823            if(!ops_stacked_write(&b64map[src[n++]&0x3f],1,errors,winfo)) 
     824                return ops_false; 
     825 
     826            arg->pos=0; 
     827            } 
     828        } 
     829 
     830    return ops_true; 
     831    } 
     832 
     833static ops_boolean_t signature_finaliser(ops_error_t **errors, 
     834                                         ops_writer_info_t *winfo) 
     835    { 
     836    base64_arg_t *arg=ops_writer_get_arg(winfo); 
     837    static char trailer[]="\r\n-----END PGP SIGNATURE-----\r\n"; 
     838 
     839    if(arg->pos) 
     840        { 
     841        if(!ops_stacked_write(&b64map[arg->t],1,errors,winfo)) 
     842            return ops_false; 
     843        if(arg->pos == 1 && !ops_stacked_write("==",2,errors,winfo)) 
     844            return ops_false; 
     845        if(arg->pos == 2 && !ops_stacked_write("=",1,errors,winfo)) 
     846            return ops_false; 
     847        } 
     848    if(!ops_stacked_write(trailer,sizeof trailer-1,errors,winfo)) 
     849        return ops_false; 
     850 
     851    return ops_true; 
     852    } 
     853 
     854typedef struct 
     855    { 
     856    unsigned pos; 
     857    } linebreak_arg_t; 
     858 
     859#define BREAKPOS        76 
     860 
     861static ops_boolean_t linebreak_writer(const unsigned char *src, 
     862                                         unsigned length, 
     863                                         ops_error_t **errors, 
     864                                         ops_writer_info_t *winfo) 
     865    { 
     866    linebreak_arg_t *arg=ops_writer_get_arg(winfo); 
     867    unsigned n; 
     868 
     869    for(n=0 ; n < length ; ++n,++arg->pos) 
     870        { 
     871        if(src[n] == '\r' || src[n] == '\n') 
     872            arg->pos=0; 
     873 
     874        if(arg->pos == BREAKPOS) 
     875            { 
     876            if(!ops_stacked_write("\r\n",2,errors,winfo)) 
     877                return ops_false; 
     878            arg->pos=0; 
     879            } 
     880        if(!ops_stacked_write(&src[n],1,errors,winfo)) 
     881            return ops_false; 
     882        } 
     883 
     884    return ops_true; 
     885    } 
     886 
     887// XXX: should return errors. 
     888void ops_writer_switch_to_signature(ops_create_info_t *info) 
     889    { 
     890    static char header[]="\r\n-----BEGIN PGP SIGNATURE-----\r\n\r\n"; 
     891 
     892    ops_writer_pop(info); 
     893    ops_write(header,sizeof header-1,info); 
     894    ops_writer_push(info,linebreak_writer,NULL,ops_writer_generic_destroyer, 
     895                    ops_mallocz(sizeof(linebreak_arg_t))); 
     896    ops_writer_push(info,base64_writer,signature_finaliser, 
     897                    ops_writer_generic_destroyer, 
     898                    ops_mallocz(sizeof(base64_arg_t))); 
     899    } 
  • openpgpsdk/trunk/src/create.c

    r307 r314  
    88#include <unistd.h> 
    99 
     10struct ops_writer_info 
     11    { 
     12    ops_writer_t *writer; 
     13    ops_writer_finaliser_t *finaliser; 
     14    ops_writer_destroyer_t *destroyer; 
     15    void *arg; 
     16    ops_writer_info_t *next; 
     17    }; 
     18 
    1019/** 
    1120 * \ingroup Create 
     
    1423struct ops_create_info 
    1524    { 
    16     ops_writer_t *writer; /*!< the writer function */ 
    17     void *arg;                  /*!< arguments for the writer function */ 
    18     ops_writer_destroyer_t *destroyer; 
     25    ops_writer_info_t winfo; 
    1926    ops_error_t *errors;        /*!< an error stack */ 
    2027    }; 
     
    2633                                ops_create_info_t *info) 
    2734    { 
    28     return info->writer(src,length,0,&info->errors,info->arg) == OPS_W_OK
     35    return info->winfo.writer(src,length,&info->errors,&info->winfo)
    2936    } 
    3037 
     
    493500    { return ops_mallocz(sizeof(ops_create_info_t)); } 
    494501 
     502static ops_boolean_t writer_info_finalise(ops_error_t **errors, 
     503                                          ops_writer_info_t *winfo) 
     504    { 
     505    ops_boolean_t ret=ops_true; 
     506 
     507    if(winfo->next && !writer_info_finalise(errors,winfo->next)) 
     508        { 
     509        winfo->finaliser=NULL; 
     510        return ops_false; 
     511        } 
     512    if(winfo->finaliser) 
     513        { 
     514        ret=winfo->finaliser(errors,winfo); 
     515        winfo->finaliser=NULL; 
     516        } 
     517    return ret; 
     518    } 
     519 
     520static void writer_info_delete(ops_writer_info_t *winfo) 
     521    { 
     522    // we should have finalised before deleting 
     523    assert(!winfo->finaliser); 
     524    if(winfo->next) 
     525        { 
     526        writer_info_delete(winfo->next); 
     527        free(winfo->next); 
     528        winfo->next=NULL; 
     529        } 
     530    if(winfo->destroyer) 
     531        { 
     532        winfo->destroyer(winfo); 
     533        winfo->destroyer=NULL; 
     534        } 
     535    winfo->writer=NULL; 
     536    } 
     537 
    495538/** 
    496539 * \ingroup Create 
     
    503546void ops_create_info_delete(ops_create_info_t *info) 
    504547    { 
    505     if(info->destroyer) 
    506         { 
    507         info->destroyer(info->arg); 
    508         info->destroyer=NULL; 
    509         } 
    510  
     548    writer_info_delete(&info->winfo); 
    511549    free(info); 
    512550    } 
     
    517555    } writer_fd_arg_t; 
    518556 
    519 static ops_writer_ret_t fd_writer(const unsigned char *src,unsigned length, 
    520                                  ops_writer_flags_t flags, 
    521                                  ops_error_t **errors,void *arg_
    522     { 
    523     writer_fd_arg_t *arg=arg_
     557static ops_boolean_t fd_writer(const unsigned char *src,unsigned length, 
     558                               ops_error_t **errors, 
     559                               ops_writer_info_t *winfo
     560    { 
     561    writer_fd_arg_t *arg=ops_writer_get_arg(winfo)
    524562    int n=write(arg->fd,src,length); 
    525  
    526     OPS_USED(flags); 
    527563 
    528564    if(n == -1) 
     
    530566        ops_system_error_1(errors,OPS_E_W_WRITE_FAILED,"write", 
    531567                           "file descriptor %d",arg->fd); 
    532         return OPS_W_ERROR
     568        return ops_false
    533569        } 
    534570 
     
    537573        ops_error_1(errors,OPS_E_W_WRITE_TOO_SHORT, 
    538574                    "file descriptor %d",arg->fd); 
    539         return OPS_W_ERROR
    540         } 
    541  
    542     return OPS_W_OK
    543     } 
    544  
    545 static void fd_destroyer(void *arg
    546     { 
    547     free(arg); 
     575        return ops_false
     576        } 
     577 
     578    return ops_true
     579    } 
     580 
     581static void fd_destroyer(ops_writer_info_t *winfo
     582    { 
     583    free(ops_writer_get_arg(winfo)); 
    548584    } 
    549585 
     
    560596 */ 
    561597 
    562 void ops_create_info_set_writer_fd(ops_create_info_t *info,int fd) 
     598void ops_writer_set_fd(ops_create_info_t *info,int fd) 
    563599    { 
    564600    writer_fd_arg_t *arg=malloc(sizeof *arg); 
    565601 
    566602    arg->fd=fd; 
    567     ops_create_info_set_writer(info,fd_writer,fd_destroyer,arg); 
    568     } 
    569  
    570 /** 
    571  * \ingroup Create 
    572  * 
    573  * Set a writer in info. If another writer has already been set, then 
    574  * that is first destroyed. 
     603    ops_writer_set(info,fd_writer,NULL,fd_destroyer,arg); 
     604    } 
     605 
     606/** 
     607 * \ingroup Create 
     608 * 
     609 * Set a writer in info. There should not be another writer set. 
    575610 * 
    576611 * \param info The info structure 
     
    579614 * \param arg The argument for the writer and destroyer 
    580615 */ 
    581 void ops_create_info_set_writer(ops_create_info_t *info, 
    582                                 ops_writer_t *writer, 
    583                                 ops_writer_destroyer_t *destroyer, 
    584                                 void *arg) 
    585     { 
    586     ops_create_info_close_writer(info); 
    587     info->writer=writer; 
    588     info->destroyer=destroyer; 
    589     info->arg=arg; 
     616void ops_writer_set(ops_create_info_t *info, 
     617                    ops_writer_t *writer, 
     618                    ops_writer_finaliser_t *finaliser, 
     619                    ops_writer_destroyer_t *destroyer, 
     620                    void *arg) 
     621    { 
     622    assert(!info->winfo.writer); 
     623    info->winfo.writer=writer; 
     624    info->winfo.finaliser=finaliser; 
     625    info->winfo.destroyer=destroyer; 
     626    info->winfo.arg=arg; 
     627    } 
     628 
     629/** 
     630 * \ingroup Create 
     631 * 
     632 * Push a writer in info. There must already be another writer set. 
     633 * 
     634 * \param info The info structure 
     635 * \param writer The writer 
     636 * \param destroyer The destroyer 
     637 * \param arg The argument for the writer and destroyer 
     638 */ 
     639void ops_writer_push(ops_create_info_t *info, 
     640                     ops_writer_t *writer, 
     641                     ops_writer_finaliser_t *finaliser, 
     642                     ops_writer_destroyer_t *destroyer, 
     643                     void *arg) 
     644    { 
     645    ops_writer_info_t *copy=ops_mallocz(sizeof *copy); 
     646 
     647    assert(info->winfo.writer); 
     648    *copy=info->winfo; 
     649    info->winfo.next=copy; 
     650 
     651    info->winfo.writer=writer; 
     652    info->winfo.finaliser=finaliser; 
     653    info->winfo.destroyer=destroyer; 
     654    info->winfo.arg=arg; 
     655    } 
     656 
     657void ops_writer_pop(ops_create_info_t *info) 
     658    { 
     659    ops_writer_info_t *next; 
     660 
     661    // Make sure the finaliser has been called. 
     662    assert(!info->winfo.finaliser); 
     663    // Makew sure this is a stacked writer 
     664    assert(info->winfo.next); 
     665    if(info->winfo.destroyer) 
     666        info->winfo.destroyer(&info->winfo); 
     667 
     668    next=info->winfo.next; 
     669    info->winfo=*next; 
     670 
     671    free(next); 
    590672    } 
    591673 
     
    597679 * \param info The info structure 
    598680 */ 
    599 void ops_create_info_close_writer(ops_create_info_t *info) 
    600     { 
    601     if(info->destroyer) 
    602         info->destroyer(info->arg); 
    603  
    604     info->writer=NULL; 
    605     info->destroyer=NULL; 
    606     info->arg=NULL; 
    607     } 
     681ops_boolean_t ops_writer_close(ops_create_info_t *info) 
     682    { 
     683    ops_boolean_t ret=writer_info_finalise(&info->errors,&info->winfo); 
     684 
     685    writer_info_delete(&info->winfo); 
     686 
     687    return ret; 
     688    } 
     689 
     690/** 
     691 * \ingroup Create 
     692 * 
     693 * Get the arg supplied to ops_create_info_set_writer(). 
     694 * 
     695 * \param winfo The writer_info structure 
     696 * \return The arg 
     697 */ 
     698void *ops_writer_get_arg(ops_writer_info_t *winfo) 
     699    { return winfo->arg; } 
     700 
     701/** 
     702 * \ingroup Create 
     703 * 
     704 * Write to the next writer down in the stack. 
     705 * 
     706 * \param src The data to write. 
     707 * \param length The length of src. 
     708 * \param flags The writer flags. 
     709 * \param errors A place to store errors. 
     710 * \param info The writer_info structure. 
     711 * \return Success - if ops_false, then errors should contain the error. 
     712 */ 
     713ops_boolean_t ops_stacked_write(const void *src,unsigned length, 
     714                                ops_error_t **errors,ops_writer_info_t *winfo) 
     715    { 
     716    return winfo->next->writer(src,length,errors,winfo->next); 
     717    } 
     718 
     719/** 
     720 * \ingroup Create 
     721 * 
     722 * Free the arg. Many writers just have a malloc()ed lump of storage, this 
     723 * function releases it. 
     724 * 
     725 * \param winfo the info structure. 
     726 */ 
     727void ops_writer_generic_destroyer(ops_writer_info_t *winfo) 
     728    { free(ops_writer_get_arg(winfo)); } 
  • openpgpsdk/trunk/src/memory.c

    r307 r314  
    5858    } 
    5959 
    60 static ops_writer_ret_t memory_writer(const unsigned char *src,unsigned length, 
    61                                       ops_writer_flags_t flags, 
     60static ops_boolean_t memory_writer(const unsigned char *src,unsigned length, 
    6261                                      ops_error_t **errors, 
    63                                       void *arg
     62                                      ops_writer_info_t *winfo
    6463    { 
    65     ops_memory_t *mem=arg
     64    ops_memory_t *mem=ops_writer_get_arg(winfo)
    6665 
    67     OPS_USED(flags); 
    6866    OPS_USED(errors); 
    6967    ops_memory_add(mem,src,length); 
    70     return OPS_W_OK
     68    return ops_true
    7169    } 
    7270 
     
    8482                                       ops_memory_t *mem) 
    8583    { 
    86     ops_create_info_set_writer(info,memory_writer,NULL,mem); 
     84    ops_writer_set(info,memory_writer,NULL,NULL,mem); 
    8785    } 
    8886 
  • openpgpsdk/trunk/src/openssl_crypto.c

    r308 r314  
    3232    } 
    3333 
    34 static ops_hash_t md5={OPS_HASH_MD5,md5_init,md5_add,md5_finish,NULL}; 
     34static ops_hash_t md5={OPS_HASH_MD5,"MD5",md5_init,md5_add,md5_finish,NULL}; 
    3535 
    3636void ops_hash_md5(ops_hash_t *hash) 
     
    6060    } 
    6161 
    62 static ops_hash_t sha1={OPS_HASH_SHA1,sha1_init,sha1_add,sha1_finish,NULL}; 
     62static ops_hash_t sha1={OPS_HASH_SHA1,"SHA1",sha1_init,sha1_add,sha1_finish, 
     63                        NULL}; 
    6364 
    6465void ops_hash_sha1(ops_hash_t *hash) 
     
    159160#endif 
    160161    } 
     162 
     163const char *ops_text_from_hash(ops_hash_t *hash) 
     164    { return hash->name; } 
  • openpgpsdk/trunk/src/signature.c

    r310 r314  
    529529    ops_write_scalar(primary,1,sig->info); 
    530530    } 
     531 
     532/** 
     533 * \ingroup Create 
     534 * 
     535 * Get the hash structure in use for the signature. 
     536 * 
     537 * \param sig The signature structure. 
     538 * \return The hash structure. 
     539 */ 
     540ops_hash_t *ops_signature_get_hash(ops_create_signature_t *sig) 
     541    { return &sig->hash; } 
     542