Changeset 314
- Timestamp:
- 11/29/05 16:06:23
- Files:
-
- openpgpsdk/trunk/examples (modified) (1 prop)
- openpgpsdk/trunk/examples/Makefile.template (modified) (3 diffs)
- openpgpsdk/trunk/examples/create-key.c (modified) (1 diff)
- openpgpsdk/trunk/examples/create-signed-key.c (modified) (2 diffs)
- openpgpsdk/trunk/examples/sign-detached.c (added)
- openpgpsdk/trunk/examples/sign-inline.c (added)
- openpgpsdk/trunk/include/openpgpsdk/armour.h (modified) (1 diff)
- openpgpsdk/trunk/include/openpgpsdk/create.h (modified) (1 diff)
- openpgpsdk/trunk/include/openpgpsdk/crypto.h (modified) (2 diffs)
- openpgpsdk/trunk/include/openpgpsdk/signature.h (modified) (3 diffs)
- openpgpsdk/trunk/src/armour.c (modified) (2 diffs)
- openpgpsdk/trunk/src/create.c (modified) (11 diffs)
- openpgpsdk/trunk/src/memory.c (modified) (2 diffs)
- openpgpsdk/trunk/src/openssl_crypto.c (modified) (3 diffs)
- openpgpsdk/trunk/src/signature.c (modified) (1 diff)
- openpgpsdk/trunk/test/91A285AE301B7D6B.pub (added)
- openpgpsdk/trunk/test/rsa-public-key-v4-A0CFDA99.raw (added)
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 7 7 LIBDEPS=common.o ../src/libops.a 8 8 LIBS=$(LIBDEPS) %CRYPTO_LIBS% %ZLIB% $(DM_LIB) %LIBS% 9 EXES=packet-dump verify create-key create-signed-key verify2 sign-detached 9 EXES=packet-dump verify create-key create-signed-key verify2 sign-detached \ 10 sign-inline 10 11 11 12 all: Makefile .depend $(EXES) … … 33 34 sign-detached: sign-detached.o $(LIBDEPS) 34 35 $(CC) $(LDFLAGS) -o sign-detached sign-detached.o $(LIBS) 36 37 sign-inline: sign-inline.o $(LIBDEPS) 38 $(CC) $(LDFLAGS) -o sign-inline sign-inline.o $(LIBS) 35 39 36 40 tags: … … 82 86 ./sign-detached $(SCRATCH)/key.sec "Why a user ID?" SHA1 $(SCRATCH)/to-be-signed-detached $(SCRATCH)/to-be-signed-detached.sig 83 87 88 test-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 84 93 include .depend openpgpsdk/trunk/examples/create-key.c
r307 r314 26 26 27 27 info=ops_create_info_new(); 28 ops_ create_info_set_writer_fd(info,1);28 ops_writer_set_fd(info,1); 29 29 30 30 ops_write_rsa_public_key(time(NULL),n,e,info); openpgpsdk/trunk/examples/create-signed-key.c
r308 r314 63 63 exit(2); 64 64 } 65 ops_ create_info_set_writer_fd(info,fd);65 ops_writer_set_fd(info,fd); 66 66 67 67 ops_write_struct_secret_key(&skey,info); 68 68 69 ops_ create_info_close_writer(info);69 ops_writer_close(info); 70 70 71 71 close(fd); … … 77 77 exit(2); 78 78 } 79 ops_ create_info_set_writer_fd(info,fd);79 ops_writer_set_fd(info,fd); 80 80 81 81 ops_write_struct_public_key(&skey.public_key,info); openpgpsdk/trunk/include/openpgpsdk/armour.h
r296 r314 1 1 #include "packet-parse.h" 2 #include "signature.h" 2 3 3 4 void ops_reader_push_dearmour(ops_parse_info_t *parse_info); 4 5 void ops_reader_pop_dearmour(ops_parse_info_t *parse_info); 6 void ops_writer_push_dash_escaped(ops_create_info_t *info, 7 ops_create_signature_t *sig); 8 void ops_writer_switch_to_signature(ops_create_info_t *info); 9 openpgpsdk/trunk/include/openpgpsdk/create.h
r307 r314 11 11 #include "errors.h" 12 12 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 13 typedef struct ops_writer_info ops_writer_info_t; 22 14 /** 23 15 * \ingroup Create 24 16 * the writer function prototype 25 17 */ 26 typedef ops_ writer_ret_t ops_writer_t(const unsigned char *src,18 typedef ops_boolean_t ops_writer_t(const unsigned char *src, 27 19 unsigned length, 28 ops_writer_flags_t flags,29 20 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); 22 typedef ops_boolean_t ops_writer_finaliser_t(ops_error_t **errors, 23 ops_writer_info_t *winfo); 24 typedef void ops_writer_destroyer_t(ops_writer_info_t *winfo); 38 25 39 26 ops_create_info_t *ops_create_info_new(void); 40 27 void 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); 28 void *ops_writer_get_arg(ops_writer_info_t *winfo); 29 ops_boolean_t ops_stacked_write(const void *src,unsigned length, 30 ops_error_t **errors, 31 ops_writer_info_t *winfo); 32 33 void 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); 38 void 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); 43 void ops_writer_pop(ops_create_info_t *info); 44 void ops_writer_generic_destroyer(ops_writer_info_t *winfo); 45 46 void ops_writer_set_fd(ops_create_info_t *info,int fd); 47 ops_boolean_t ops_writer_close(ops_create_info_t *info); 43 48 44 49 ops_boolean_t ops_write(const void *src,unsigned length, openpgpsdk/trunk/include/openpgpsdk/crypto.h
r304 r314 19 19 { 20 20 ops_hash_algorithm_t algorithm; 21 const char *name; 21 22 ops_hash_init_t *init; 22 23 ops_hash_add_t *add; … … 31 32 void ops_hash_any(ops_hash_t *hash,ops_hash_algorithm_t alg); 32 33 ops_hash_algorithm_t ops_hash_algorithm_from_text(const char *hash); 34 const char *ops_text_from_hash(ops_hash_t *hash); 33 35 unsigned ops_hash_size(ops_hash_algorithm_t alg); 34 36 openpgpsdk/trunk/include/openpgpsdk/signature.h
r307 r314 1 1 /** \file 2 2 */ 3 4 #ifndef OPS_SIGNATURE_H 5 #define OPS_SIGNATURE_H 3 6 4 7 #include "packet.h" … … 37 40 void ops_signature_add_data(ops_create_signature_t *sig,const void *buf, 38 41 size_t length); 42 ops_hash_t *ops_signature_get_hash(ops_create_signature_t *sig); 39 43 void ops_signature_hashed_subpackets_end(ops_create_signature_t *sig); 40 44 void ops_write_signature(ops_create_signature_t *sig,ops_public_key_t *key, … … 45 49 void ops_signature_add_primary_user_id(ops_create_signature_t *sig, 46 50 ops_boolean_t primary); 51 52 #endif openpgpsdk/trunk/src/armour.c
r307 r314 3 3 #include <openpgpsdk/util.h> 4 4 #include <openpgpsdk/crypto.h> 5 #include <openpgpsdk/create.h> 6 #include <openpgpsdk/signature.h> 5 7 6 8 #include <string.h> … … 707 709 free(arg); 708 710 } 711 712 typedef 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 719 static 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 752 void 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. 760 void 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 775 typedef struct 776 { 777 unsigned pos; 778 unsigned char t; 779 } base64_arg_t; 780 781 static char b64map[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" 782 "0123456789+/"; 783 784 static 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 833 static 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 854 typedef struct 855 { 856 unsigned pos; 857 } linebreak_arg_t; 858 859 #define BREAKPOS 76 860 861 static 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. 888 void 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 8 8 #include <unistd.h> 9 9 10 struct 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 10 19 /** 11 20 * \ingroup Create … … 14 23 struct ops_create_info 15 24 { 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; 19 26 ops_error_t *errors; /*!< an error stack */ 20 27 }; … … 26 33 ops_create_info_t *info) 27 34 { 28 return info->w riter(src,length,0,&info->errors,info->arg) == OPS_W_OK;35 return info->winfo.writer(src,length,&info->errors,&info->winfo); 29 36 } 30 37 … … 493 500 { return ops_mallocz(sizeof(ops_create_info_t)); } 494 501 502 static 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 520 static 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 495 538 /** 496 539 * \ingroup Create … … 503 546 void ops_create_info_delete(ops_create_info_t *info) 504 547 { 505 if(info->destroyer) 506 { 507 info->destroyer(info->arg); 508 info->destroyer=NULL; 509 } 510 548 writer_info_delete(&info->winfo); 511 549 free(info); 512 550 } … … 517 555 } writer_fd_arg_t; 518 556 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_;557 static 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); 524 562 int n=write(arg->fd,src,length); 525 526 OPS_USED(flags);527 563 528 564 if(n == -1) … … 530 566 ops_system_error_1(errors,OPS_E_W_WRITE_FAILED,"write", 531 567 "file descriptor %d",arg->fd); 532 return OPS_W_ERROR;568 return ops_false; 533 569 } 534 570 … … 537 573 ops_error_1(errors,OPS_E_W_WRITE_TOO_SHORT, 538 574 "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 581 static void fd_destroyer(ops_writer_info_t *winfo) 582 { 583 free(ops_writer_get_arg(winfo)); 548 584 } 549 585 … … 560 596 */ 561 597 562 void ops_ create_info_set_writer_fd(ops_create_info_t *info,int fd)598 void ops_writer_set_fd(ops_create_info_t *info,int fd) 563 599 { 564 600 writer_fd_arg_t *arg=malloc(sizeof *arg); 565 601 566 602 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. 575 610 * 576 611 * \param info The info structure … … 579 614 * \param arg The argument for the writer and destroyer 580 615 */ 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; 616 void 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 */ 639 void 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 657 void 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); 590 672 } 591 673 … … 597 679 * \param info The info structure 598 680 */ 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 } 681 ops_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 */ 698 void *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 */ 713 ops_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 */ 727 void ops_writer_generic_destroyer(ops_writer_info_t *winfo) 728 { free(ops_writer_get_arg(winfo)); } openpgpsdk/trunk/src/memory.c
r307 r314 58 58 } 59 59 60 static ops_writer_ret_t memory_writer(const unsigned char *src,unsigned length, 61 ops_writer_flags_t flags, 60 static ops_boolean_t memory_writer(const unsigned char *src,unsigned length, 62 61 ops_error_t **errors, 63 void *arg)62 ops_writer_info_t *winfo) 64 63 { 65 ops_memory_t *mem= arg;64 ops_memory_t *mem=ops_writer_get_arg(winfo); 66 65 67 OPS_USED(flags);68 66 OPS_USED(errors); 69 67 ops_memory_add(mem,src,length); 70 return OPS_W_OK;68 return ops_true; 71 69 } 72 70 … … 84 82 ops_memory_t *mem) 85 83 { 86 ops_ create_info_set_writer(info,memory_writer,NULL,mem);84 ops_writer_set(info,memory_writer,NULL,NULL,mem); 87 85 } 88 86 openpgpsdk/trunk/src/openssl_crypto.c
r308 r314 32 32 } 33 33 34 static ops_hash_t md5={OPS_HASH_MD5, md5_init,md5_add,md5_finish,NULL};34 static ops_hash_t md5={OPS_HASH_MD5,"MD5",md5_init,md5_add,md5_finish,NULL}; 35 35 36 36 void ops_hash_md5(ops_hash_t *hash) … … 60 60 } 61 61 62 static ops_hash_t sha1={OPS_HASH_SHA1,sha1_init,sha1_add,sha1_finish,NULL}; 62 static ops_hash_t sha1={OPS_HASH_SHA1,"SHA1",sha1_init,sha1_add,sha1_finish, 63 NULL}; 63 64 64 65 void ops_hash_sha1(ops_hash_t *hash) … … 159 160 #endif 160 161 } 162 163 const char *ops_text_from_hash(ops_hash_t *hash) 164 { return hash->name; } openpgpsdk/trunk/src/signature.c
r310 r314 529 529 ops_write_scalar(primary,1,sig->info); 530 530 } 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 */ 540 ops_hash_t *ops_signature_get_hash(ops_create_signature_t *sig) 541 { return &sig->hash; } 542
