Method and device for batch signature verification of multiple pages of PDF documents based on shared signature value method
By using shared signature value objects and incremental update technology in PDF documents, the problem of poor batch signature and stamp verification performance of PDF documents in the prior art is solved, and an efficient stamp signature and stamp verification process is achieved.
Patent Information
- Application Number
- CN202111289440.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-02
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2041-11-02
AI Technical Summary
The prior art shows that when performing multi-page batch signatures and inspections of PDF documents, the performance is poor and cannot meet the real-time requirements. This is mainly because each page of the signature requires digital signature calculation of the document data.
Using a shared signature value method, a signature value object is generated for sharing, reducing the time for recalculating the summary and generating PDF signature value object, and updating the signature domain and graphic objects to PDF documents through incremental updates.
It improves the electronic signature and seal verification speed of PDF documents, reduces the generation size of signature and seal verification, and improves work efficiency, especially when processing multi-page PDF documents.
Smart Images

Figure CN114117543B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of electronic signatures, and in particular relates to a method and device for verifying batch signatures of multiple pages of PDF documents based on a shared signature value method. Background Art
[0002] Electronic signature is the process of signing electronic documents with electronic seals, which can effectively confirm the source of electronic documents, ensure the integrity of documents, prevent unauthorized tampering of documents, and ensure the non-repudiation of signature behavior. PDF (Portable Document Format) files have good rendering effects, compression capabilities, and cross-platform features, and are widely used in e-commerce and e-government automated office systems. Especially in bidding applications, most of the bidding PDF files are very large and have many pages. Such PDF files need to be signed and verified in batches with multiple pages, and high real-time requirements are required.
[0003] The usual practice for electronic signature of PDF documents is that each electronic signature needs to digitally sign all the data in the PDF, and append the signature field and signature value increment to the PDF document. For the application scenario of batch signing of large PDF files with many pages, the digital signature calculation must be performed on the document data (including the data of the previous signature) for each page signed. This results in poor signing and verification performance and cannot meet real-time requirements. Summary of the invention
[0004] The main purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art and provide a method, system and storage medium for batch signing and verification of multiple pages of PDF documents based on a shared signature value method. The present invention uses a shared signature value object method to reduce the time for recalculating the digest and generating the PDF signature value object, optimizes the signing and verification process, improves the speed of electronic signing and verification of PDF documents, and further improves work efficiency.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] On one hand, the present invention provides a method for batch signing and verifying multiple pages of a PDF document based on a shared signature value method, and the signing method comprises the following steps:
[0007] S01. Respond to the signature request and read the stamp position, stamp page range and required stamp image of the PDF document;
[0008] S02, loading the PDF document data stream and parsing the PDF document;
[0009] S03. Generate a signature value object for sharing, where the shared signature value object includes the byte range of the signature original and the digital signature content attributes;
[0010] S04, generating a graphic object according to the required seal image, the content of which is the data stream of the seal image;
[0011] S05. Generate multiple signature field objects at the same time according to the number of pages to be stamped, set the page attribute of the signature field to reference the corresponding page object, set the signature value attribute of all signature field objects to reference the shared signature value object generated in S03, and the image appearance attribute of the signature field to reference the graphic object generated in S04;
[0012] S06. The generated multiple signature field objects, graphic objects and shared signature value objects are updated to the PDF document using an incremental update method.
[0013] S07. Calculate the signature byte range of the shared signature value object, where the signature byte range of the shared signature value object includes PDF original document information, multiple signature domain objects, and graphic object information;
[0014] S08. Obtain the data to be signed according to the signature byte range of the shared signature value object, calculate and generate a digital signature, set the digital signature content attribute of the shared signature value object to the generated digital signature, and generate a new PDF document;
[0015] The steps of the seal verification method are as follows:
[0016] S09, responding to the seal verification request, loading the PDF document data stream, and parsing the PDF document;
[0017] S10, parsing all signature fields with digital signatures in the PDF document;
[0018] S11. Traverse all electronic signature information of the PDF document and verify it.
[0019] Preferably, in step S02, the parsing of the PDF electronic document is specifically:
[0020] S21, read the cross-reference table of the PDF document to obtain the file locations of all objects in the document;
[0021] S22, parsing the file tail of the PDF document to find the document directory object;
[0022] S23, read the page tree object from the document directory object;
[0023] S24, obtaining the number of pages and an object array of page tree object nodes from the page tree object;
[0024] S25, traversing the object array of the page tree object node, parsing the content object element information of each page of the signature document;
[0025] S26, reading the interactive form object array from the document directory object, traversing the interactive form object array, and determining whether it is a signature field according to the type;
[0026] S27. Determine whether the signature field has a digital signature based on whether the signature value attribute of the signature field is empty, and traverse to obtain all signature fields with digital signatures in the current document.
[0027] Preferably, in step S03, generating a signature value object for sharing is specifically:
[0028] S31, generating a PDF data dictionary object, and setting the type attribute of the data dictionary object to digital signature;
[0029] S32, set the encoding type of the data dictionary object to the digital signature encoding format of pkcs#7;
[0030] S33, presetting the content value of the data dictionary object to a string of all '0's;
[0031] S34. Set the content attribute of the data dictionary object to the hexadecimal encoding of the digital signature value to obtain a shared signature value object.
[0032] Preferably, in step S05, the generating of multiple signature domain objects is specifically:
[0033] S51. Generate multiple data dictionary objects according to the number of pages that need to be signed, and set the data dictionary object field type to the signature field;
[0034] S52, finding the page object according to the stamped page index number, and setting the data dictionary object page attribute to reference the corresponding page object;
[0035] S53, according to the size of the stamp position, set the value of the area position attribute of the data dictionary object;
[0036] S54, setting the appearance attribute of the data dictionary object to the graphic object generated in S04;
[0037] S55. Set the signature value attribute of the data dictionary object to the shared signature value object described in S03.
[0038] Preferably, in step S06, the updating to the PDF document using an incremental update method is specifically as follows:
[0039] S61, converting and encoding multiple signature field objects, graphic objects, and shared signature value objects into binary data streams, and appending them to the end of the original PDF document data stream in sequence;
[0040] S62, generating a new cross-reference table and a file end according to the position of the appended object;
[0041] S63: append the new cross-reference table and the file footer to the PDF file data stream in sequence to complete the update.
[0042] Preferably, in step S07, the signature byte range of the shared signature value object is calculated as follows:
[0043] S71, generating a data stream according to the updated PDF document, and calculating the total length of the data stream to be S;
[0044] S72, calculate the position from the beginning of the data stream to the content attribute of the shared signature value object, represented by the symbol L;
[0045] S73, calculate the length N of the string value from the beginning of the data stream to the content attribute of the shared signature value object;
[0046] S74. Calculate the signature byte range of the shared signature value object to be 0 to L in length and (L+N) to S in length.
[0047] Preferably, in step S11, the specific verification steps are:
[0048] Verify each electronic signature and check whether it is a verified shared signature value object based on the byte range and digital signature value of the signature value object corresponding to each electronic signature;
[0049] If it is a verified shared signature value object, the verification result of the verified shared signature value object is returned.
[0050] If it is not a verified shared signature value object, the electronic signature is fully verified. After the verification is completed, the byte range, digital signature value and verification result of the signature value object corresponding to the electronic signature are cached and marked as a verified shared signature value object.
[0051] On the other hand, the present invention provides a PDF document multi-page batch signature verification system based on a shared signature value method, which is applied to the PDF document multi-page batch signature verification method based on a shared signature value method, including a document reading module, a parsing module, a dictionary generation module, a signature domain generation module, an incremental update module, a signature byte calculation module, a signature generation module and a seal verification module;
[0052] The document reading module is used to read the required document information according to different requests; when requesting for signature, the seal position, seal page range and required seal image of the PDF document are read in; when requesting for seal verification, the PDF document is read in;
[0053] The parsing module is used to parse different document information according to different requests; when requesting for signature, it loads the PDF document data stream and parses the PDF document; when requesting for seal verification, it loads the PDF document data stream and parses the PDF document and all its signature fields with digital signatures;
[0054] The dictionary generation module is used to generate a signature value object for sharing, and to generate a graphic object according to the required seal image;
[0055] The signature field generation module is used to generate multiple signature field objects at the same time according to the number of pages to be stamped, set the page attribute of the signature field to reference the corresponding page object, the signature value attributes of all signature field objects to reference the generated shared signature value object, and the picture appearance attribute of the signature field to reference the generated graphic object;
[0056] The incremental update module is used to update the generated multiple signature domain objects, graphic objects and shared signature value objects to the PDF document using an incremental update method;
[0057] The signature byte calculation module is used to calculate the signature byte range of the shared signature value object;
[0058] The signature generation module is used to obtain the data to be signed according to the signature byte range of the shared signature value object, calculate and generate a digital signature, set the digital signature content attribute of the shared signature value object to the generated digital signature, and generate a new PDF document;
[0059] The seal verification module is used to traverse all electronic signature information of the PDF document parsed by the parsing module under the seal verification request and verify it.
[0060] Another aspect of the present invention provides an electronic device, the electronic device comprising:
[0061] at least one processor; and,
[0062] a memory communicatively connected to the at least one processor; wherein,
[0063] The memory stores computer program instructions executable by the at least one processor, the computer program
[0064] The instruction is executed by the at least one processor so that the at least one processor can execute the PDF document multi-page batch stamping method based on the shared signature value method.
[0065] On the other hand, the present invention provides a computer-readable storage medium storing a program, which, when executed by a processor, implements the method for batch signing and verifying multiple pages of PDF documents based on a shared signature value method.
[0066] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0067] 1. The present invention utilizes the method of referencing a shared signature value object in the signature field, thereby reducing a large amount of time for recalculating the summary. When performing electronic signature on multiple pages of PDF, the speed is basically the same as that of electronic signature on a single page of PDF.
[0068] 2. The present invention reduces the generation of a large number of PDF signature value objects by using the signature field to reference the shared signature value object, and can greatly reduce the size of the generated electronic document, especially for PDF documents with more than 100 pages.
[0069] 3. The present invention utilizes the method of using the signature field to reference a shared signature value object. In the subsequent electronic signature verification process, multiple pages of electronic signatures share the same signature value. The same signature value object only needs to be verified once, and multi-page PDF electronic signatures can be verified with high performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0071] Figure 1 It is a flow chart of the signing method in the method for signing and verifying multiple pages of PDF documents in batches based on the shared signature value method according to an embodiment of the present invention;
[0072] FIG. 2( a ) and FIG. 2( b ) are schematic diagrams of the structure of an existing electronic signature structure and a new PDF electronic signature document generated according to an embodiment of the present invention;
[0073] Figure 3 It is a flow chart of a seal verification method in a method for batch signature verification of multiple pages of a PDF document based on a shared signature value method according to an embodiment of the present invention;
[0074] Figure 4 This is a schematic diagram of the structure of a PDF document multi-page batch signature verification system based on a shared signature value method according to an embodiment of the present invention;
[0075] Figure 5 It is a structural schematic diagram of an electronic device according to an embodiment of the present invention;
[0076] Figure 6 It is a schematic diagram of the structure of a computer-readable storage medium according to an embodiment of the present invention. DETAILED DESCRIPTION
[0077] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.
[0078] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments.
[0079] In one embodiment of the present application, a method for batch signing and verifying multiple pages of a PDF document based on a common signature value method is provided, such as Figure 1 As shown, the signing method includes the following steps:
[0080] S01. Respond to the signature request and read the stamp position, stamp page range and required stamp image of the PDF document;
[0081] S02, loading PDF document data stream, parsing PDF electronic document;
[0082] S03. Generate a signature value object for sharing, the signature value object contains information such as the byte range of the signature original text and the digital signature content attributes;
[0083] S04, generating a graphic object according to the required seal image, the content of which is the data stream of the seal image;
[0084] S05. Generate multiple signature field objects at the same time according to the number of pages to be stamped, set the page attribute of the signature field to reference the corresponding page object, set the signature value attribute of all signature field objects to reference the shared signature value object generated in S03, and the image appearance attribute of the signature field to reference the graphic object generated in S04;
[0085] S06. The generated multiple signature field objects, graphic objects and shared signature value objects are updated to the PDF document using an incremental update method.
[0086] S07. Calculate the signature byte range of the shared signature value object, where the signature byte range of the shared signature value object includes PDF original document information, multiple signature domain objects, and graphic object information;
[0087] S08. Obtain the data to be signed according to the signature byte range of the shared signature value object, calculate and generate a digital signature, set the digital signature content attribute of the shared signature value object to the generated digital signature, and generate a new PDF document. The existing electronic signature structure is shown in Figure 2(a), and the new electronic signature structure is shown in Figure 2(b).
[0088] Further, such as Figure 3 As shown, the steps of seal verification method are as follows:
[0089] S09, responding to the seal verification request, loading the PDF document data stream, and parsing the PDF document;
[0090] S10, parsing all signature fields with digital signatures in the PDF document;
[0091] S11. Traverse all electronic signature information of the PDF document and verify it.
[0092] Furthermore, in step S02, parsing the PDF electronic document includes the following steps:
[0093] S21, read the cross-reference table of the PDF document to obtain the file locations of all objects in the document;
[0094] S22, parsing the file tail of the PDF document to find the document directory object;
[0095] S23, read the page tree object from the document directory object;
[0096] S24, obtaining the number of pages and an object array of page tree object nodes from the page tree object;
[0097] S25, traversing the object array of the page tree object node, parsing the content object element information of each page of the signature document;
[0098] S26, reading the interactive form object array from the document directory object, traversing the interactive form object array, and determining whether it is a signature field according to the type;
[0099] S27. Determine whether the signature field has a digital signature based on whether the signature value attribute of the signature field is empty, and traverse to obtain all signature fields with digital signatures in the current document.
[0100] Furthermore, in step S03, a signature value object for sharing is generated, and the specific steps are as follows:
[0101] S31, generating a PDF data dictionary object, and setting the type attribute of the data dictionary object to digital signature;
[0102] S32, set the encoding type of the data dictionary object to the digital signature encoding format of pkcs#7;
[0103] S33, presetting the content value of the data dictionary object to a string of all '0's;
[0104] S34. Set the content attribute of the data dictionary object to the hexadecimal encoding of the digital signature value to obtain a shared signature value object.
[0105] Furthermore, in step S05, the steps of generating multiple signature domain objects are:
[0106] S51. Generate multiple data dictionary objects according to the number of pages that need to be signed, and set the data dictionary object field type to the signature field;
[0107] S52, finding the page object according to the stamped page index number, and setting the data dictionary object page attribute to reference the corresponding page object;
[0108] S53, according to the size of the stamp position, set the value of the area position attribute of the data dictionary object;
[0109] S54, setting the appearance attribute of the data dictionary object to the graphic object generated in S04;
[0110] S55. Set the signature value attribute of the data dictionary object to the shared signature value object described in S03.
[0111] Furthermore, in step S06, an incremental update is used to update the PDF document, specifically:
[0112] S61, converting and encoding multiple signature field objects, graphic objects, and shared signature value objects into binary data streams, and appending them to the end of the original PDF document data stream in sequence;
[0113] S62, generating a new cross-reference table and a file end according to the position of the appended object;
[0114] S63: append the new cross-reference table and the file footer to the PDF file data stream in sequence to complete the update.
[0115] Further, in step S07, the signature byte range of the shared signature value object is calculated, specifically:
[0116] S71, generating a data stream according to the updated PDF document, and calculating the total length of the data stream to be S;
[0117] S72, calculate the position from the beginning of the data stream to the content attribute of the shared signature value object, represented by symbol L;
[0118] S73, calculate the length N of the string value from the beginning of the data stream to the content attribute of the shared signature value object;
[0119] S74. Calculate the signature byte range of the shared signature value object to be 0 to L in length and (L+N) to S in length.
[0120] Furthermore, in step S10, the specific steps of verification are:
[0121] Verify each electronic signature and check whether it is a verified shared signature value object based on the byte range and digital signature value of the signature value object corresponding to each electronic signature;
[0122] If the verified shared signature value is exclusive, the verification result of the verified shared signature value object is returned.
[0123] If it is not a verified shared signature value object, the electronic signature is fully verified. After the verification is completed, the byte range, digital signature value and verification result of the signature value object corresponding to the electronic signature are cached and marked as a verified shared signature value object.
[0124] It should be noted that, for the sake of convenience, the aforementioned method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited to the described order of actions, because according to the present invention, certain steps can be performed in other orders or simultaneously.
[0125] Based on the same idea as the PDF document multi-page batch signature verification method based on the shared signature value method in the above-mentioned embodiment, the present invention also provides a PDF document multi-page batch signature verification system based on the shared signature value method, which can be used to execute the above-mentioned PDF document multi-page batch signature verification method based on the shared signature value method. For ease of explanation, in the structural schematic diagram of an embodiment of a PDF document multi-page batch signature verification system based on the shared signature value method, only the parts related to the embodiment of the present invention are shown. Those skilled in the art can understand that the illustrated structure does not constitute a limitation on the device, and may include more or fewer components than shown in the diagram, or combine certain components, or arrange the components differently.
[0126] See also Figure 4 In another embodiment of the present application, a PDF document multi-page batch signature verification system 100 based on a shared signature value method is provided, the system comprising a document reading module 101, a parsing module 102, a dictionary generation module 103, a signature domain generation module 104, an incremental update module 105, a signature byte calculation module 106, a signature generation module 107 and a seal verification module 108;
[0127] The document reading module 101 is used to read the required document information according to different requests; when requesting for signature, it reads the seal position, seal page range and required seal image of the PDF document; when requesting for seal verification, it reads the PDF electronic signature document;
[0128] The parsing module 102 is used to parse different document information according to different requests; when requesting for signature, it loads the PDF document data stream and parses the PDF document; when requesting for seal verification, it loads the PDF electronic signature document data stream and parses the PDF electronic signature document and all its signature fields with digital signatures;
[0129] The dictionary generation module 103 is used to generate a signature value object for sharing; and to generate a graphic object according to the required seal image;
[0130] The signature field generation module 104 is used to generate multiple signature field objects at the same time according to the number of pages to be stamped, set the page attribute of the signature field to reference the corresponding page object, the signature value attributes of all signature field objects to reference the generated shared signature value object, and the image appearance attribute of the signature field to reference the generated graphic object;
[0131] The incremental update module 105 is used to update the generated multiple signature domain objects, graphic objects and shared signature value objects to the PDF document using an incremental update method;
[0132] The signature byte calculation module 106 is used to calculate the signature byte range of the signature value dictionary;
[0133] The signature generation module 107 is used to obtain the data to be signed according to the signature byte range of the shared signature value object, calculate and generate a digital signature, set the digital signature content attribute of the shared signature value object to the generated digital signature, and generate a new PDF electronic signature document;
[0134] The seal verification module 108 is used to traverse all the electronic signature information of the PDF electronic signature document parsed by the parsing module under the seal verification request and perform verification.
[0135] It should be noted that the system for batch signing and verifying multiple pages of PDF documents based on a shared signature value method of the present invention corresponds one to one with the method for batch signing and verifying multiple pages of PDF documents based on a shared signature value method of the present invention. The technical features and beneficial effects described in the embodiment of the method for batch signing and verifying multiple pages of PDF documents based on a shared signature value method are applicable to the embodiment of a system for batch signing and verifying multiple pages of PDF documents based on a shared signature value method. For specific contents, please refer to the description in the embodiment of the method of the present invention, which will not be repeated here. This is hereby declared.
[0136] In addition, in the implementation of a PDF document multi-page batch signature and seal verification system based on a shared signature value method in the above-mentioned embodiment, the logical division of each program module is only an example. In actual applications, the above-mentioned functions can be assigned to different program modules as needed, for example, for the configuration requirements of the corresponding hardware or the convenience of software implementation. That is, the internal structure of the PDF document multi-page batch signature and seal verification system based on a shared signature value method is divided into different program modules to complete all or part of the functions described above.
[0137] See also Figure 5 In one embodiment, an electronic device for a method for batch signing multiple pages of a PDF document based on a shared signature value is provided. The electronic device 200 may include a first processor 201, a first memory 202 and a bus, and may also include a computer program stored in the first memory 202 and executable on the first processor 201, such as a program 203 for batch signing multiple pages of a PDF document based on a shared signature value.
[0138] The first memory 202 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the first memory 202 can be an internal storage unit of the electronic device 200, such as a mobile hard disk of the electronic device 200. In other embodiments, the first memory 202 can also be an external storage device of the electronic device 200, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 200. Further, the first memory 202 can also include both an internal storage unit of the electronic device 200 and an external storage device. The first memory 202 can not only be used to store application software and various types of data installed in the electronic device 200, such as the code of the PDF document multi-page batch signature program 203 based on the shared signature value method, but also can be used to temporarily store data that has been output or is to be output.
[0139] In some embodiments, the first processor 201 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The first processor 201 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules stored in the first memory 202 (for example, a PDF document multi-page batch signature program based on a shared signature value method, etc.), and calls data stored in the first memory 202 to execute various functions of the electronic device 200 and process data.
[0140] Figure 5 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 5 The structure shown does not constitute a limitation on the electronic device 200 , and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0141] The PDF document multi-page batch signing program 203 based on the shared signature value method stored in the first memory 202 of the electronic device 200 is a combination of multiple instructions. When running in the first processor 201, it can achieve:
[0142] S01, respond to the signature request, read the stamp position, stamp page range and required stamp image of the PDF document;
[0143] S02, loading PDF document data stream, parsing PDF electronic document;
[0144] S03. Generate a signature value object for sharing, where the shared signature value object includes the byte range of the signature original and the digital signature content attributes;
[0145] S04, generating a graphic object according to the required seal image, the content of which is the data stream of the seal image;
[0146] S05. Generate multiple signature field objects at the same time according to the number of pages to be stamped, set the page attribute of the signature field to reference the corresponding page object, set the signature value attribute of all signature field objects to reference the generated shared signature value object, and set the image appearance attribute of the signature field to reference the generated graphic object;
[0147] S06. The generated multiple signature field objects, graphic objects and shared signature value objects are updated to the PDF document using an incremental update method.
[0148] S07. Calculate the signature byte range of the shared signature value object, where the signature byte range of the shared signature value object includes PDF original document information, multiple signature domain objects, and graphic object information;
[0149] S08. Obtain the data to be signed according to the signature byte range of the shared signature value object, calculate and generate a digital signature, set the digital signature content attribute of the shared signature value object to the generated digital signature, and generate a new PDF document;
[0150] The steps of the seal verification method are as follows:
[0151] S09, responding to the seal verification request, loading the PDF document data stream, and parsing the PDF document;
[0152] S10, parsing all signature fields with digital signatures in the PDF document;
[0153] S11. Traverse all electronic signature information of the PDF document and verify it.
[0154] Furthermore, if the module / unit integrated in the electronic device 200 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer-readable storage medium. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).
[0155] See also Figure 6 In one embodiment, a computer-readable storage medium 300 is provided, in which a program is stored in a memory 301. When the program is executed by a processor 302, the method for batch signing and verifying multiple pages of a PDF document based on a shared signature value is implemented, specifically:
[0156] The signing method includes the following steps:
[0157] S01, respond to the signature request, read the stamp position, stamp page range and required stamp image of the PDF document;
[0158] S02, loading PDF document data stream, parsing PDF electronic document;
[0159] S03. Generate a signature value object for sharing, where the shared signature value object includes the byte range of the signature original and the digital signature content attributes;
[0160] S04, generating a graphic object according to the required seal image, the content of which is the data stream of the seal image;
[0161] S05. Generate multiple signature field objects at the same time according to the number of pages to be stamped, set the page attribute of the signature field to reference the corresponding page object, set the signature value attribute of all signature field objects to reference the generated shared signature value object, and set the image appearance attribute of the signature field to reference the generated graphic object;
[0162] S06. The generated multiple signature field objects, graphic objects and shared signature value objects are updated to the PDF document using an incremental update method;
[0163] S07. Calculate the signature byte range of the shared signature value object, where the signature byte range of the shared signature value object includes PDF original document information, multiple signature domain objects, and graphic object information;
[0164] S08. Obtain the data to be signed according to the signature byte range of the shared signature value object, calculate and generate a digital signature, set the digital signature content attribute of the shared signature value object to the generated digital signature, and generate a new PDF document;
[0165] The steps for seal verification are as follows:
[0166] S09, responding to the seal verification request, loading the PDF document data stream, and parsing the PDF document;
[0167] S10, parsing all signature fields with digital signatures in the PDF electronic signature document;
[0168] S11. Traverse all electronic signature information of the PDF electronic signature document and verify it.
[0169] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0170] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0171] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.
Claims
1. A method for batch signature verification of multiple pages of PDF documents based on a shared signature value method, characterized in that: The steps include: S01. Respond to the signature request and read the stamp position, stamp page range and required stamp image of the PDF document; S02, loading the PDF document data stream and parsing the PDF document; In step S02, the PDF document is parsed as follows: S21, read the cross-reference table of the PDF document to obtain the file locations of all objects in the document; S22, parsing the file tail of the PDF document to find the document directory object; S23, read the page tree object from the document directory object; S24, obtaining the number of pages and an object array of page tree object nodes from the page tree object; S25, traversing the object array of the page tree object node, parsing the content object element information of each page of the signature document; S26, reading the interactive form object array from the document directory object, traversing the interactive form object array, and determining whether it is a signature field according to the type; S27, judging whether the signature value attribute of the signature field is empty or not, and traversing to obtain all the signature fields with digital signatures in the current document; S03. Generate a signature value object for sharing, where the shared signature value object includes the byte range of the signature original and the digital signature content attributes; S04, generating a graphic object according to the required seal image, the content of which is the data stream of the seal image; S05. Generate multiple signature field objects at the same time according to the number of pages to be stamped, set the page attribute of the signature field to reference the corresponding page object, set the signature value attribute of all signature field objects to reference the shared signature value object generated in S03, and the image appearance attribute of the signature field to reference the graphic object generated in S04; S06. The generated multiple signature field objects, graphic objects and shared signature value objects are updated to the PDF document using an incremental update method; S07. Calculate the signature byte range of the shared signature value object, where the signature byte range of the shared signature value object includes PDF original document information, multiple signature domain objects, and graphic object information; S08. Obtain the data to be signed according to the signature byte range of the shared signature value object, calculate and generate a digital signature, set the digital signature content attribute of the shared signature value object to the generated digital signature, and generate a new PDF document; The steps of the seal verification method are as follows: S09, responding to the seal verification request, loading the PDF document data stream, and parsing the PDF document; S10, parsing all signature fields with digital signatures in the PDF document; S11. Traverse all electronic signature information of the PDF document and verify it.
2. According to claim 1, the method for batch signature verification of multiple pages of PDF documents based on the shared signature value mode is characterized in that: In step S03, the generation of a signature value object for sharing is specifically: S31, generating a PDF data dictionary object, and setting the type attribute of the data dictionary object to digital signature; S32, set the encoding type of the data dictionary object to the digital signature encoding format of pkcs#7; S33, presetting the content value of the data dictionary object to a string of all '0's; S34. Set the content attribute of the data dictionary object to the hexadecimal encoding of the digital signature value to obtain a shared signature value object.
3. According to the method for batch signing and verifying multiple pages of PDF documents based on the shared signature value method of claim 1, it is characterized in that: In step S05, the generation of multiple signature domain objects is specifically as follows: S51. Generate multiple data dictionary objects according to the number of pages that need to be signed, and set the data dictionary object field type to the signature field; S52, finding the page object according to the stamped page index number, and setting the data dictionary object page attribute to reference the corresponding page object; S53, according to the size of the stamp position, set the value of the area position attribute of the data dictionary object; S54, setting the appearance attribute of the data dictionary object to the graphic object generated in S04; S55. Set the signature value attribute of the data dictionary object to the shared signature value object described in S03.
4. According to claim 1, the method for batch signature verification of multiple pages of PDF documents based on the shared signature value mode is characterized in that: In step S06, the updating to the PDF document using an incremental update method is specifically as follows: S61, converting and encoding multiple signature field objects, graphic objects, and shared signature value objects into binary data streams, and appending them to the end of the original PDF document data stream in sequence; S62, generating a new cross-reference table and a file end according to the position of the appended object; S63: append the new cross-reference table and the file footer to the PDF file data stream in sequence to complete the update.
5. According to claim 1, the method for batch signature verification of multiple pages of PDF documents based on shared signature value mode is characterized in that: In step S07, the signature byte range of the shared signature value object is calculated as follows: S71, generating a data stream according to the updated PDF document, and calculating that the total length of the data stream is S; S72, calculate the position from the beginning of the data stream to the content attribute of the shared signature value object, represented by symbol L; S73, calculate the length N of the string value from the beginning of the data stream to the content attribute of the shared signature value object; S74. Calculate the signature byte range of the shared signature value object to be 0~L length and (L+N)~S length.
6. According to claim 1, the method for batch signature verification of multiple pages of PDF documents based on shared signature value mode is characterized in that: In step S11, the specific verification steps are: Verify each electronic signature and check whether it is a verified shared signature value object based on the byte range and digital signature value of the signature value object corresponding to each electronic signature; If it is a verified shared signature value object, return the verification result of the verified shared signature value object; If it is not a verified shared signature value object, the electronic signature is fully verified. After the verification is completed, the byte range, digital signature value and verification result of the signature value object corresponding to the electronic signature are cached and marked as a verified shared signature value object.
7. A PDF document multi-page batch signature verification system based on a shared signature value method, characterized in that: A method for batch signing and verifying multiple pages of a PDF document based on a shared signature value method, applied to any one of claims 1-6, comprising a document reading module, a parsing module, a dictionary generation module, a signature domain generation module, an incremental update module, a signature byte calculation module, a signature generation module and a seal verification module; The document reading module is used to read the required document information according to different requests; when requesting for signature, the seal position, seal page range and required seal image of the PDF document are read in; when requesting for seal verification, the PDF document is read in; The parsing module is used to parse different document information according to different requests; when requesting for signature, it loads the PDF document data stream and parses the PDF document; when requesting for seal verification, it loads the PDF document data stream and parses the PDF document and all its signature fields with digital signatures; The dictionary generation module is used to generate a signature value object for sharing, and to generate a graphic object according to the required seal image; The signature field generation module is used to generate multiple signature field objects at the same time according to the number of pages to be stamped, set the page attribute of the signature field to reference the corresponding page object, the signature value attributes of all signature field objects to reference the generated shared signature value object, and the image appearance attribute of the signature field to reference the generated graphic object; The incremental update module is used to update the generated multiple signature domain objects, graphic objects and shared signature value objects to the PDF document using an incremental update method; The signature byte calculation module is used to calculate the signature byte range of the shared signature value object; The signature generation module is used to obtain the data to be signed according to the signature byte range of the shared signature value object, calculate and generate a digital signature, set the digital signature content attribute of the shared signature value object to the generated digital signature, and generate a new PDF electronic signature document; The seal verification module is used to traverse all the electronic signature information of the PDF electronic signature document parsed by the parsing module under the seal verification request and verify it.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores computer program instructions executable by the at least one processor, the computer program The instruction is executed by the at least one processor so that the at least one processor can execute the PDF document multi-page batch stamping method based on the shared signature value method as described in any one of claims 1-6.
9. A computer-readable storage medium storing a program, characterized in that: When the program is executed by a processor, the method for batch signing and verifying multiple pages of a PDF document based on a shared signature value method as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
PDF signature method and PDF signature system
CN110532811A