Changeset 619
- Timestamp:
- 09/08/08 17:53:43
- Files:
-
- openpgpsdk/trunk/include/openpgpsdk/packet.h (modified) (1 diff)
- openpgpsdk/trunk/include/openpgpsdk/util.h (modified) (1 diff)
- openpgpsdk/trunk/include/openpgpsdk/validate.h (modified) (3 diffs)
- openpgpsdk/trunk/include/openpgpsdk/writer.h (modified) (1 diff)
- openpgpsdk/trunk/src/doxygen.c (modified) (6 diffs)
- openpgpsdk/trunk/src/lib/accumulate.c (modified) (2 diffs)
- openpgpsdk/trunk/src/lib/compress.c (modified) (1 diff)
- openpgpsdk/trunk/src/lib/create.c (modified) (4 diffs)
- openpgpsdk/trunk/src/lib/crypto.c (modified) (2 diffs)
- openpgpsdk/trunk/src/lib/keyring.c (modified) (5 diffs)
- openpgpsdk/trunk/src/lib/keyring_local.h (modified) (1 diff)
- openpgpsdk/trunk/src/lib/openssl_crypto.c (modified) (2 diffs)
- openpgpsdk/trunk/src/lib/packet-show.c (modified) (18 diffs)
- openpgpsdk/trunk/src/lib/parse_local.h (modified) (1 diff)
- openpgpsdk/trunk/src/lib/reader.c (modified) (3 diffs)
- openpgpsdk/trunk/src/lib/signature.c (modified) (31 diffs)
- openpgpsdk/trunk/src/lib/util.c (modified) (2 diffs)
- openpgpsdk/trunk/src/lib/validate.c (modified) (4 diffs)
- openpgpsdk/trunk/tests/test_rsa_decrypt.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openpgpsdk/trunk/include/openpgpsdk/packet.h
r616 r619 586 586 } ops_signature_info_t; 587 587 588 typedef struct 589 { 590 ops_signature_info_t info; 588 /** Struct used when parsing a signature */ 589 typedef struct 590 { 591 ops_signature_info_t info; /*!< The signature information */ 591 592 /* The following fields are only used while parsing the signature */ 592 593 unsigned char hash2[2]; /*!< high 2 bytes of hashed value - for quick test */ openpgpsdk/trunk/include/openpgpsdk/util.h
r616 r619 50 50 #define OPS_ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a))) 51 51 52 /** Allocate zeroed memory */53 52 void *ops_mallocz(size_t n); 54 53 openpgpsdk/trunk/include/openpgpsdk/validate.h
r602 r619 51 51 } validate_reader_arg_t; 52 52 53 /** Struct used with the validate_key_cb callback */ 53 54 typedef struct 54 55 { … … 70 71 } validate_key_cb_arg_t; 71 72 73 /** Struct use with the validate_data_cb callback */ 72 74 typedef struct 73 75 { … … 76 78 LITERAL_DATA, 77 79 SIGNED_CLEARTEXT 78 } use; 80 } use; /*<! this is set to indicate what kind of data we have */ 79 81 union 80 82 { 81 ops_literal_data_body_t literal_data_body; 82 ops_signed_cleartext_body_t signed_cleartext_body; 83 } data; 84 unsigned char hash[OPS_MAX_HASH_SIZE]; 85 const ops_keyring_t *keyring; 86 validate_reader_arg_t *rarg; 87 ops_validate_result_t *result; 88 } validate_data_cb_arg_t; 83 ops_literal_data_body_t literal_data_body; /*<! Used to hold Literal Data */ 84 ops_signed_cleartext_body_t signed_cleartext_body; /*<! Used to hold Signed Cleartext */ 85 } data; /*<! the data itself */ 86 unsigned char hash[OPS_MAX_HASH_SIZE]; /*<! the hash */ 87 const ops_keyring_t *keyring; /*<! keyring to use */ 88 validate_reader_arg_t *rarg; /*<! reader-specific arg */ 89 ops_validate_result_t *result; /*<! where to put the result */ 90 } validate_data_cb_arg_t; /*<! used with validate_data_cb callback */ 89 91 90 92 ops_boolean_t ops_check_signature(const unsigned char *hash, openpgpsdk/trunk/include/openpgpsdk/writer.h
r574 r619 50 50 ops_writer_info_t *winfo); 51 51 typedef void ops_writer_destroyer_t(ops_writer_info_t *winfo); 52 /** Writer settings */ 52 53 struct ops_writer_info 53 54 { 54 ops_writer_t *writer; 55 ops_writer_finaliser_t *finaliser; 56 ops_writer_destroyer_t *destroyer; 57 void *arg; 58 ops_writer_info_t *next; 55 ops_writer_t *writer; /*!< the writer itself */ 56 ops_writer_finaliser_t *finaliser; /*!< the writer's finaliser */ 57 ops_writer_destroyer_t *destroyer; /*!< the writer's destroyer */ 58 void *arg; /* writer-specific argument */ 59 ops_writer_info_t *next; /*!< next writer in the stack */ 59 60 }; 60 61 openpgpsdk/trunk/src/doxygen.c
r613 r619 52 52 */ 53 53 54 /** \defgroup HighLevel_Misc Miscellaneous 54 /** \defgroup HighLevel_Signature Signatures and Verification 55 \ingroup HighLevelAPI 56 */ 57 58 /** \defgroup HighLevel_SignatureSign Sign File or Buffer 59 \ingroup HighLevel_Signature 60 */ 61 62 /** \defgroup HighLevel_SignatureVerify Verify File or Buffer 63 \ingroup HighLevel_Signature 64 */ 65 66 /** \defgroup HighLevel_SignatureDetails Verify Signature Details 67 \ingroup HighLevel_Signature 68 */ 69 70 /** \defgroup HighLevel_Cryption Encryption and Decryption 55 71 \ingroup HighLevelAPI 56 72 */ … … 62 78 63 79 /** 80 \defgroup HighLevel_Print Print 81 \ingroup HighLevelAPI 82 */ 83 84 /** 85 \defgroup HighLevel_General General 86 \ingroup HighLevelAPI 87 */ 88 89 /** 64 90 \defgroup HighLevel_KeyringRead Read Keyring 65 91 \ingroup HighLevel_Keyring … … 77 103 78 104 /** 105 \defgroup HighLevel_KeyGenerate Generate Key 106 \ingroup HighLevel_Keyring 107 */ 108 109 /** 110 \defgroup HighLevel_KeyWrite Write Key 111 \ingroup HighLevel_Keyring 112 */ 113 114 /** 115 \defgroup HighLevel_KeyGeneral Other Key Functions 116 \ingroup HighLevel_Keyring 117 */ 118 119 /** 79 120 \defgroup HighLevel_KeyringMemory Memory Ops 80 \ingroup HighLevel_Keyring81 */82 83 /**84 \defgroup HighLevel_Key Key85 121 \ingroup HighLevel_Keyring 86 122 */ … … 130 166 */ 131 167 168 /** \defgroup Core_Signature Signatures and Verification 169 \ingroup CoreAPI 170 */ 171 172 /** \defgroup Core_Compress Compression and Decompression 173 \ingroup CoreAPI 174 */ 175 132 176 /** \defgroup Core_Misc Miscellaneous 133 177 \ingroup CoreAPI … … 141 185 /** 142 186 \defgroup Core_Callbacks Callbacks 143 \ingroup CoreAPI144 */145 146 /**147 \defgroup Create148 187 \ingroup CoreAPI 149 188 */ … … 196 235 */ 197 236 /** 198 * @defgroup C reate Create199 * \ingroup AdvancedAPI237 * @defgroup Core_Create Create 238 * \ingroup CoreAPI 200 239 * These functions allow an OpenPGP object to be created. 201 240 * openpgpsdk/trunk/src/lib/accumulate.c
r574 r619 126 126 127 127 /** 128 * \ingroup Parse128 * \ingroup Core_Parse 129 129 * 130 130 * Parse packets from an input stream until EOF or error. … … 133 133 * 134 134 * \param keyring Pointer to an existing keyring 135 * \param optOptions to use when parsing135 * \param parse_info Options to use when parsing 136 136 */ 137 137 openpgpsdk/trunk/src/lib/compress.c
r574 r619 233 233 234 234 /** 235 * \ingroup Utils235 * \ingroup Core_Compress 236 236 * 237 237 * \param *region Pointer to a region 238 238 * \param *parse_info How to parse 239 * \param type Which compression type to expect 239 240 */ 240 241 openpgpsdk/trunk/src/lib/create.c
r617 r619 405 405 406 406 /** 407 \ingroup HighLevel_Key 407 \ingroup HighLevel_KeyWrite 408 408 409 409 \brief Writes a transferable PGP public key to the given output stream. … … 483 483 484 484 /** 485 \ingroup HighLevel_Key 485 \ingroup HighLevel_KeyWrite 486 486 487 487 \brief Writes a transferable PGP secret key to the given output stream. … … 1048 1048 1049 1049 /** 1050 \ingroup HighLevelAPI 1050 \ingroup HighLevel_General 1051 1052 \brief Reads contents of file into new ops_memory_t struct. 1053 1054 \param filename Filename to read from 1055 \param errnum Pointer to error 1056 \return new ops_memory_t struct containing the contents of the file 1051 1057 1052 \return allocated memory. If there was an error opening the file or reading from it, errnum is set to the cause 1058 \note If there was an error opening the file or reading from it, errnum is set to the cause 1059 1060 \note It is the caller's responsibility to call ops_memory_free(mem) 1053 1061 */ 1054 1062 … … 1092 1100 } 1093 1101 1102 /** 1103 \ingroup HighLevel_General 1104 1105 \brief Reads contents of buffer into file 1106 1107 \param filename Filename to write to 1108 \param buf Buffer to write to file 1109 \param len Size of buffer 1110 \param overwrite Flag to set whether to overwrite an existing file 1111 \return 1 if OK; 0 if error 1112 */ 1113 1094 1114 int ops_write_file_from_buf(const char *filename, const char* buf, const size_t len, const ops_boolean_t overwrite) 1095 1115 { openpgpsdk/trunk/src/lib/crypto.c
r616 r619 140 140 callback_write_parsed(const ops_parser_content_t *content_,ops_parse_cb_info_t *cbinfo); 141 141 142 /** 143 \ingroup HighLevel_Cryption 144 Encrypt a file 145 \param input_filename Name of file to be encrypted 146 \param output_filename Name of file to write to. If NULL, name is constructed from input_filename 147 \param pub_key Public Key to encrypt file for 148 \param use_armour Write armoured text, if set 149 \param allow_overwrite Allow output file to be overwrwritten if it exists 150 \return ops_true if OK; else ops_false 151 */ 142 152 ops_boolean_t ops_encrypt_file(const char* input_filename, const char* output_filename, const ops_keydata_t *pub_key, const ops_boolean_t use_armour, const ops_boolean_t allow_overwrite) 143 153 { … … 198 208 } 199 209 200 /* 201 the output filename can either be given explicitly, or if NULL, 202 it will be derived from the input filename following GPG conventions. 203 That is, we assume a binary encrypted file will be called <origfile>.gpg 204 and an armoured file will be called <origfile.asc> 205 If neither is true, then we add a .decrypted suffix. 210 /** 211 \ingroup HighLevel_Cryption 212 \param input_filename Name of file to be decrypted 213 \param output_filename Name of file to write to. If NULL, the filename is constructed from the input filename, following GPG conventions. 214 \param keyring Keyring to use 215 \param use_armour Expect armoured text, if set 216 \param allow_overwrite Allow output file to overwritten, if set. 217 \param cb_get_passphrase Callback to use to get passphrase 206 218 */ 207 219 openpgpsdk/trunk/src/lib/keyring.c
r611 r619 94 94 95 95 /** 96 \ingroup HighLevel_Key 96 \ingroup HighLevel_KeyGeneral 97 97 98 98 \brief Returns the public key in the given keydata. … … 113 113 114 114 /** 115 \ingroup HighLevel_Key 115 \ingroup HighLevel_KeyGeneral 116 116 117 117 \brief Check whether this is a secret key or not. … … 122 122 123 123 /** 124 \ingroup HighLevel_Key 124 \ingroup HighLevel_KeyGeneral 125 125 126 126 \brief Returns the secret key in the given keydata. … … 141 141 142 142 /** 143 \ingroup HighLevel_Key 143 \ingroup HighLevel_KeyGeneral 144 144 145 145 \brief Returns the secret key in the given keydata. … … 275 275 276 276 /** 277 \ingroup HighLevel_Key 277 \ingroup HighLevel_KeyGeneral 278 278 279 279 \brief Checks whether key's algorithm and type are supported by OpenPGP::SDK openpgpsdk/trunk/src/lib/keyring_local.h
r570 r619 41 41 42 42 43 /** sigpacket_t */ 43 44 typedef struct 44 45 { openpgpsdk/trunk/src/lib/openssl_crypto.c
r616 r619 307 307 { return hash->name; } 308 308 309 /** 310 \ingroup HighLevel_KeyGenerate 311 \brief Generates an RSA keypair 312 \param numbits Modulus size 313 \param e Public Exponent 314 \param keydata Pointer to keydata struct to hold new key 315 \return ops_true if key generated successfully; otherwise ops_false 316 \note It is the caller's responsibility to call ops_keydata_free(keydata) 317 */ 309 318 ops_boolean_t ops_rsa_generate_keypair(const int numbits, const unsigned long e, ops_keydata_t* keydata) 310 319 { … … 395 404 } 396 405 406 /** 407 \ingroup HighLevel_KeyGenerate 408 \brief Creates a self-signed RSA keypair 409 \param numbits Modulus size 410 \param e Public Exponent 411 \param userid User ID 412 \return The new keypair or NULL 413 414 \note It is the caller's responsibility to call ops_keydata_free(keydata) 415 \sa ops_rsa_generate_keypair() 416 */ 397 417 ops_keydata_t* ops_rsa_create_selfsigned_keypair(const int numbits, const unsigned long e, ops_user_id_t * userid) 398 418 { openpgpsdk/trunk/src/lib/packet-show.c
r616 r619 526 526 527 527 /** 528 * \ingroup Show528 * \ingroup HighLevel_Print 529 529 * returns description of the Packet Tag 530 530 * \param packet_tag … … 543 543 544 544 /** 545 * \ingroup Show545 * \ingroup HighLevel_Print 546 546 * 547 547 * returns description of the Signature Sub-Packet type … … 555 555 556 556 /** 557 * \ingroup Show557 * \ingroup HighLevel_Print 558 558 * 559 559 * returns description of the Revocation Reason code … … 568 568 569 569 /** 570 * \ingroup Show570 * \ingroup HighLevel_Print 571 571 * 572 572 * returns description of the given Signature type … … 581 581 582 582 /** 583 * \ingroup Show583 * \ingroup HighLevel_Print 584 584 * 585 585 * returns description of the given Public Key Algorithm … … 594 594 595 595 /** 596 * \ingroup Show596 * \ingroup HighLevel_Print 597 597 * returns description of the Preferred Compression 598 598 * \param octet … … 605 605 606 606 /** 607 * \ingroup Show607 * \ingroup HighLevel_Print 608 608 * 609 609 * returns set of descriptions of the given Preferred Compression Algorithms … … 621 621 622 622 /** 623 * \ingroup Show623 * \ingroup HighLevel_Print 624 624 * 625 625 * returns description of the Hash Algorithm type … … 635 635 636 636 /** 637 * \ingroup Show637 * \ingroup HighLevel_Print 638 638 * 639 639 * returns set of descriptions of the given Preferred Hash Algorithms … … 655 655 656 656 /** 657 * \ingroup Show657 * \ingroup HighLevel_Print 658 658 * returns description of the given Preferred Symmetric Key Algorithm 659 659 * \param octet … … 667 667 668 668 /** 669 * \ingroup Show669 * \ingroup HighLevel_Print 670 670 * 671 671 * returns set of descriptions of the given Preferred Symmetric Key Algorithms … … 682 682 683 683 /** 684 * \ingroup Show684 * \ingroup HighLevel_Print 685 685 * returns description of one SS Feature 686 686 * \param octet … … 696 696 697 697 /** 698 * \ingroup Show698 * \ingroup HighLevel_Print 699 699 * 700 700 * returns set of descriptions of the given SS Features … … 740 740 741 741 /** 742 * \ingroup Show742 * \ingroup HighLevel_Print 743 743 * returns description of SS Key Flag 744 744 * \param octet … … 753 753 754 754 /** 755 * \ingroup Show755 * \ingroup HighLevel_Print 756 756 * 757 757 * returns set of descriptions of the given Preferred Key Flags … … 795 795 796 796 /** 797 * \ingroup Show797 * \ingroup HighLevel_Print 798 798 * 799 799 * returns description of one given Key Server Preference … … 812 812 813 813 /** 814 * \ingroup Show814 * \ingroup HighLevel_Print 815 815 * returns set of descriptions of given Key Server Preferences 816 816 * \param ss_key_server_prefs … … 855 855 856 856 /** 857 * \ingroup Show857 * \ingroup HighLevel_Print 858 858 * 859 859 * returns set of descriptions of the given SS Notation Data Flags openpgpsdk/trunk/src/lib/parse_local.h
r574 r619 45 45 46 46 47 /* 48 * ops_crypt_info49 */47 /** ops_crypt_info 48 Encrypt/decrypt settings 49 */ 50 50 struct ops_crypt_info 51 51 { 52 char *passphrase; 53 ops_keyring_t *keyring; 54 const ops_keydata_t *keydata; 55 ops_parse_cb_t *cb_get_passphrase; 52 char *passphrase; /*<! passphrase to use, this is set by cb_get_passphrase */ 53 ops_keyring_t *keyring; /*<! keyring to use */ 54 const ops_keydata_t *keydata; /*<! keydata to use */ 55 ops_parse_cb_t *cb_get_passphrase; /*<! callback to use to get the passphrase */ 56 56 }; 57 57 openpgpsdk/trunk/src/lib/reader.c
r613 r619 39 39 * \ingroup Internal_Readers_Generic 40 40 * \brief Starts reader stack 41 * \param pinfo 42 * \param reader 43 * \param arg 41 * \param pinfo Parse settings 42 * \param reader Reader to use 43 * \param destroyer Destroyer to use 44 * \param arg Reader-specific arg 44 45 */ 45 46 void ops_reader_set(ops_parse_info_t *pinfo,ops_reader_t *reader,ops_reader_destroyer_t *destroyer,void *arg) … … 53 54 * \ingroup Internal_Readers_Generic 54 55 * \brief Adds to reader stack 55 * \param pinfo 56 * \param reader 57 * \param arg 56 * \param pinfo Parse settings 57 * \param reader Reader to use 58 * \param arg Reader-specific arg 58 59 */ 59 60 void ops_reader_push(ops_parse_info_t *pinfo,ops_reader_t *reader,ops_reader_destroyer_t *destroyer,void *arg) … … 75 76 * \ingroup Internal_Readers_Generic 76 77 * \brief Removes from reader stack 77 * \param pinfo 78 * \param pinfo Parse settings 78 79 */ 79 80 void ops_reader_pop(ops_parse_info_t *pinfo) openpgpsdk/trunk/src/lib/signature.c
r617 r619 37 37 38 38 static int debug=0; 39 #define MAXBUF 1024 40 41 /** \ingroup C reate39 #define MAXBUF 1024 /*<! Standard buffer size to use */ 40 41 /** \ingroup Core_Create 42 42 * needed for signature creation 43 43 */ … … 53 53 }; 54 54 55 /** 56 \ingroup Core_Signature 57 Creates new ops_create_signature_t 58 \return new ops_create_signature_t 59 \note It is the caller's responsibility to call ops_create_signature_delete() 60 \sa ops_create_signature_delete() 61 */ 55 62 ops_create_signature_t *ops_create_signature_new() 56 63 { return ops_mallocz(sizeof(ops_create_signature_t)); } 57 64 65 /** 66 \ingroup Core_Signature 67 Free signature and memory associated with it 68 \param sig struct to free 69 \sa ops_create_signature_new() 70 */ 58 71 void ops_create_signature_delete(ops_create_signature_t *sig) 59 72 { … … 70 83 0x03,0x02,0x1A,0x05,0x00,0x04,0x14 }; 71 84 85 /** 86 \ingroup Core_Create 87 implementation of EMSA-PKCS1-v1_5, as defined in OpenPGP RFC 88 \param M 89 \param mLen 90 \param hash_alg Hash algorithm to use 91 \param EM 92 \return ops_true if OK; else ops_false 93 */ 72 94 ops_boolean_t encode_hash_buf(const unsigned char *M, size_t mLen, 73 95 const ops_hash_algorithm_t hash_alg, … … 81 103 int n=0; 82 104 ops_hash_t hash; 83 // unsigned char hashout[OPS_MAX_HASH_SIZE];84 105 int hash_sz=0; 85 106 int encoded_hash_sz=0; … … 324 345 } 325 346 347 /** 348 \ingroup Core_Signature 349 \brief Checks a signature 350 \param hash Signature Hash to be checked 351 \param length Signature Length 352 \param sig The Signature to be checked 353 \param signer The signer's public key 354 \return ops_true if good; else ops_false 355 */ 326 356 ops_boolean_t ops_check_signature(const unsigned char *hash,unsigned length, 327 357 const ops_signature_t *sig, … … 376 406 377 407 /** 378 * \ingroup Verify379 * 380 * Verify a certification signature.408 * \ingroup HighLevel_SignatureDetails 409 * 410 * \brief Verify a certification signature. 381 411 * 382 412 * \param key The public key that was signed. … … 385 415 * \param signer The public key of the signer. 386 416 * \param raw_packet The raw signature packet. 417 * \return ops_true if OK; else ops_false 387 418 */ 388 419 ops_boolean_t … … 409 440 410 441 /** 411 * \ingroup Verify442 * \ingroup HighLevel_SignatureDetails 412 443 * 413 444 * Verify a certification signature. … … 418 449 * \param signer The public key of the signer. 419 450 * \param raw_packet The raw signature packet. 451 * \return ops_true if OK; else ops_false 420 452 */ 421 453 ops_boolean_t … … 441 473 442 474 /** 443 * \ingroup Verify475 * \ingroup HighLevel_SignatureDetails 444 476 * 445 477 * Verify a subkey signature. … … 450 482 * \param signer The public key of the signer. 451 483 * \param raw_packet The raw signature packet. 484 * \return ops_true if OK; else ops_false 452 485 */ 453 486 ops_boolean_t … … 467 500 468 501 /** 469 * \ingroup Verify502 * \ingroup HighLevel_SignatureDetails 470 503 * 471 504 * Verify a direct signature. … … 475 508 * \param signer The public key of the signer. 476 509 * \param raw_packet The raw signature packet. 510 * \return ops_true if OK; else ops_false 477 511 */ 478 512 ops_boolean_t … … 489 523 490 524 /** 491 * \ingroup Verify525 * \ingroup Core_Signature 492 526 * 493 527 * Verify a signature on a hash (the hash will have already been fed … … 498 532 * \param sig The signature to be verified. 499 533 * \param signer The public key of the signer. 534 * \return ops_true if OK; else ops_false 500 535 */ 501 536 ops_boolean_t … … 530 565 531 566 /** 532 * \ingroup C reate567 * \ingroup Core_Signature 533 568 * 534 569 * ops_signature_start() creates a V4 public key signature with a SHA1 hash. … … 567 602 568 603 /** 569 * \ingroup C reate604 * \ingroup Core_Signature 570 605 * 571 606 * Create a V4 public key signature over some cleartext. … … 600 635 } 601 636 637 /** 638 * \ingroup Core_Signature 639 */ 602 640 void ops_signature_start_cleartext_signature(ops_create_signature_t *sig, 603 641 const ops_secret_key_t *key, … … 608 646 } 609 647 648 /** 649 * \ingroup Core_Signature 650 */ 610 651 void ops_signature_start_message_signature(ops_create_signature_t *sig, 611 652 const ops_secret_key_t *key, … … 617 658 618 659 /** 619 * \ingroup C reate660 * \ingroup Core_Signature 620 661 * 621 662 * Add plaintext data to a signature-to-be. … … 634 675 635 676 /** 636 * \ingroup C reate677 * \ingroup Core_Signature 637 678 * 638 679 * Mark the end of the hashed subpackets in the signature … … 653 694 654 695 /** 655 * \ingroup C reate696 * \ingroup Core_Signature 656 697 * 657 698 * Write out a signature … … 718 759 719 760 /** 720 * \ingroup C reate761 * \ingroup Core_Signature 721 762 * 722 763 * ops_signature_add_creation_time() adds a creation time to the signature. … … 732 773 733 774 /** 734 * \ingroup C reate775 * \ingroup Core_Signature 735 776 * 736 777 * Adds issuer's key ID to the signature … … 748 789 749 790 /** 750 * \ingroup C reate791 * \ingroup Core_Signature 751 792 * 752 793 * Adds primary user ID to the signature … … 763 804 764 805 /** 765 * \ingroup C reate806 * \ingroup Core_Signature 766 807 * 767 808 * Get the hash structure in use for the signature. … … 773 814 { return &sig->hash; } 774 815 816 /** 817 \ingroup HighLevel_SignatureSign 818 Sign a file with a Cleartext Signature 819 \param filename Filename to be signed 820 \param skey Secret Key to sign with 821 \param overwrite Allow output file to be overwritten, if set 822 */ 775 823 ops_boolean_t ops_sign_file_as_cleartext(const char* filename, const ops_secret_key_t *skey, const ops_boolean_t overwrite) 776 824 { … … 865 913 866 914 867 /* It is the calling function's responsibility to free signed_cleartext */ 868 /* signed_cleartext should be a NULL pointer when passed in */ 915 /** 916 * \ingroup HighLevel_SignatureSign 917 * \param cleartext Text to be signed 918 * \param len Length of text 919 * \param signed_cleartext ops_memory_t struct in which to write the signed cleartext 920 * \param skey Secret key with which to sign the cleartext 921 * \return ops_true if OK; else ops_false 922 * \note It is the calling function's responsibility to free signed_cleartext 923 * \note signed_cleartext should be a NULL pointer when passed in 924 */ 869 925 ops_boolean_t ops_sign_buf_as_cleartext(const char* cleartext, const size_t len, ops_memory_t** signed_cleartext, const ops_secret_key_t *skey) 870 926 { … … 921 977 } 922 978 979 /** 980 \ingroup HighLevel_SignatureSign 981 \brief Sign a file 982 \param input_filename Input filename 983 \param output_filename Output filename. If NULL, a name is constructed from the input filename. 984 \param skey Secret Key to use for signing 985 \param use_armour Write armoured text, if set. 986 \param overwrite May overwrite existing file, if set. 987 \return ops_true if OK; else ops_false; 988 */ 923 989 ops_boolean_t ops_sign_file(const char* input_filename, const char* output_filename, const ops_secret_key_t *skey, const ops_boolean_t use_armour, const ops_boolean_t overwrite) 924 990 { … … 1014 1080 } 1015 1081 1082 /** 1083 \ingroup HighLevel_SignatureSign 1084 \brief Signs input text; returns ops_memory_t struct containing signed input text. 1085 \param input Input text to be signed 1086 \param input_len Length of input text 1087 \param sig_type Signature type 1088 \param skey Secret Key 1089 \param use_armour Write armoured text, if set 1090 \return New ops_memory_t struct containing signed text 1091 \note It is the caller's responsibility to call ops_memory_free(me) 1092 */ 1016 1093 ops_memory_t* ops_sign_mem(const void* input, const int input_len, const ops_sig_type_t sig_type, const ops_secret_key_t *skey, const ops_boolean_t use_armour) 1017 1094 { … … 1026 1103 1027 1104 ops_hash_algorithm_t hash_alg=OPS_HASH_SHA1; 1028 // ops_sig_type_t sig_type=OPS_SIG_BINARY;1029 1105 ops_literal_data_type_t ld_type; 1030 1106 ops_hash_t* hash=NULL; openpgpsdk/trunk/src/lib/util.c
r613 r619 194 194 /** 195 195 \ingroup Internal_Readers_Sum16 196 \param pinfo Parse settings 196 197 */ 197 198 … … 205 206 /** 206 207 \ingroup Internal_Readers_Sum16 208 \param pinfo Parse settings 209 \return sum 207 210 */ 208 211 unsigned short ops_reader_pop_sum16(ops_parse_info_t *pinfo) openpgpsdk/trunk/src/lib/validate.c
r616 r619 491 491 } 492 492 493 /* 493 /** 494 * \ingroup HighLevel_SignatureVerify 494 495 * Validate all signatures on a single key against the given keyring 496 * \param result Where to put the result 497 * \param key Key to validate 498 * \param keyring Keyring to use for validation 499 * \param cb_get_passphrase Callback to use to get passphrase 500 * \note It is the caller's responsiblity to free result after use. 501 * \sa ops_validate_result_free() 495 502 */ 496 503 void ops_validate_key_signatures(ops_validate_result_t *result,const ops_keydata_t *key, … … 530 537 } 531 538 539 /** 540 \ingroup HighLevel_SignatureVerify 541 \param result Where to put the result 542 \param ring Keyring to use 543 \param cb_get_passphrase Callback to use to get passphrase 544 \note It is the caller's responsibility to free result after use. 545 \sa ops_validate_result_free() 546 */ 532 547 void ops_validate_all_signatures(ops_validate_result_t *result, 533 548 const ops_keyring_t *ring, 534 ops_parse_cb_return_t cb (const ops_parser_content_t *, ops_parse_cb_info_t *)535 )549 ops_parse_cb_return_t cb_get_passphrase (const ops_parser_content_t *, ops_parse_cb_info_t *) 550 ) 536 551 { 537 552 int n; … … 539 554 memset(result,'\0',sizeof *result); 540 555 for(n=0 ; n < ring->nkeys ; ++n) 541 ops_validate_key_signatures(result,&ring->keys[n],ring, cb); 542 } 543 556 ops_validate_key_signatures(result,&ring->keys[n],ring, cb_get_passphrase); 557 } 558 559 /** 560 \ingroup HighLevel_SignatureVerify 561 Free result and associated memory 562 \param result Struct to be freed 563 */ 544 564 void ops_validate_result_free(ops_validate_result_t *result) 545 565 { … … 558 578 } 559 579 580 /** 581 \ingroup HighLevel_SignatureVerify 582 \param result Where to put the result 583 \param filename Name of file to be validated 584 \param armoured Treat file as armoured, if set 585 \param keyring Keyring to use 586 \return ops_true if signature validate successfully; ops_false if not 587 \note After verification, result holds the details of all keys which 588 have passed, failed and not been recognised. 589 \note It is the caller's responsiblity to call ops_validate_result_free(result) after use. 590 */ 560 591 ops_boolean_t ops_validate_file(ops_validate_result_t *result, const char* filename, const int armoured, const ops_keyring_t* keyring) 561 592 { openpgpsdk/trunk/tests/test_rsa_decrypt.c
r607 r619 156 156 if (has_armour) 157 157 ops_reader_push_dearmour(pinfo,ops_false,ops_false,ops_false); 158 // current_passphrase=has_passphrase ? bravo_passphrase : nopassphrase;159 158 160 159 // setup for writing parsed data to mem_out
