<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

    <title type="text" xml:lang="en">Gökçen Eraslan - Yere Düşünce Derneği</title>
    <link rel="self" type="application/atom+xml" href="http://blog.yeredusuncedernegi.com/feed/english.xml" />
    <link rel="alternate" type="text/html" href="http://blog.yeredusuncedernegi.com" />
    <updated>2013-05-10T03:21:06-07:00</updated>
    <id>http://blog.yeredusuncedernegi.com</id>
    <author>
        <name>Gökçen Eraslan</name>
    </author>
    <rights>Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported</rights>

    
    <entry>
        <title>GSoC Final</title>
        <link href="http://blog.yeredusuncedernegi.com/category/english/2012-08-24/gsoc-final" />
        <updated>2012-08-24T00:00:00-07:00</updated>
        <id>http://blog.yeredusuncedernegi.com/category/english/2012-08-24/gsoc-final</id>
        <content type="html">&lt;p&gt;After the GSoC midterm, there were two remaining important objectives to do: to write the NSS code to create a PKCS7 object (which includes the actual signature, encrypted SHA1 digest and the public certificate) and to improve the PDF signing GUI (which can be tested only in the experimental mode).&lt;/p&gt;

&lt;p&gt;For the NSS part, first I have used the NSS &lt;a href='https://developer.mozilla.org/en-US/docs/NSS/PKCS_7_functions'&gt;PKCS7 API&lt;/a&gt; (secpkcs7.h and pkcs7t.h) to create the PKCS7 object. But it was very hard for me since NSS lacks a proper &lt;a href='https://developer.mozilla.org/en-US/docs/NSS/PKCS_7_functions'&gt;documentation&lt;/a&gt; (the one in the header files is not sufficient). Anyway, later on, I have decided to use the new and more fine grained NSS CMS (Cryptographic Message Syntax) &lt;a href='http://www.mozilla.org/projects/security/pki/nss/ref/nssfunctions.html#smime'&gt;API&lt;/a&gt; (cms.h and cmst.h).&lt;/p&gt;

&lt;p&gt;I have followed following steps to create a PKCS7 object:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;We need a NSS CERTCertificate structure to operate on the NSS world. So, DER encoded certificate data is obtained via the &lt;a href='http://api.libreoffice.org/docs/common/ref/com/sun/star/security/XCertificate.html#Encoded'&gt;Encoded attribute&lt;/a&gt; of XCertificate and converted to a CERTCertificate structure using the &lt;code&gt;CERT_DecodeCertFromPackage&lt;/code&gt; function.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;SHA1 sum of the PDF file is computed using the &lt;code&gt;HASH_Create&lt;/code&gt;, &lt;code&gt;HASH_Begin&lt;/code&gt;, &lt;code&gt;HASH_Update&lt;/code&gt; and &lt;code&gt;HASH_End&lt;/code&gt; &lt;a href='http://www.mozilla.org/projects/security/pki/nss/ref/nssfunctions.html#utils'&gt;functions&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;PKCS7 object is created:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;An empty CMS message is created using &lt;code&gt;NSS_CMSMessage_Create&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;A SignedData is created inside the CMS message using the &lt;code&gt;NSS_CMSSignedData_Create&lt;/code&gt; function.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Since we use a detached PKCS7 object (which means that the PKCS7 signature object contains only the signature part, excluding the data itself) for the signing, an empty Data object is created inside the SignedData using &lt;code&gt;NSS_CMSContentInfo_SetContent_Data&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Certificate chain and signer info is added to the SignedData, using &lt;code&gt;NSS_CMSSignerInfo_IncludeCerts&lt;/code&gt; and &lt;code&gt;NSS_CMSSignedData_AddSignerInfo&lt;/code&gt; respectively.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;SHA1 is added to the CMS message using &lt;code&gt;NSS_CMSSignedData_SetDigestValue&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;CMS message is DER-encoded via &lt;code&gt;NSS_CMSEncoder_Start&lt;/code&gt; and &lt;code&gt;NSS_CMSEncoder_Finish&lt;/code&gt;. (&lt;code&gt;NSS_CMSEncoder_Update&lt;/code&gt; is not used since we don&amp;#8217;t have a Data).&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Finally, DER encoded PKCS object is converted to the HEX representation and written to the relevant structure of the PDF which is prepared in the earlier commits.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And for the GUI part, I have used Thunderbird certificate selection GUI design in the PDF export dialog. Now, the selected certificate information is printed in a disabled Edit control and users are able to clear the selected certificate to cancel the signing operation. (I have also used the &lt;code&gt;PassWord = True&lt;/code&gt; property in the .src file for the certificate password input.)&lt;/p&gt;

&lt;p&gt;At the end of the day, however, Adobe acroread shows the PDF signatures as invalid for some reason. But, it shows the certificate details correctly (which was not the case when I have used the old NSS PKCS7 API). So it seems DER/HEX encodings and the inclusion of the certificate chain are correct but there is a bug, apparently. Maybe the calculation of SHA1 or passing the private key password to NSS is wrong. I will try to figure it out soon.&lt;/p&gt;

&lt;p&gt;Thanks to kendy and sberg for their devoted support in this GSoC project.&lt;/p&gt;</content>
    </entry>
    
    <entry>
        <title>The first half of GSoC 2012 is over</title>
        <link href="http://blog.yeredusuncedernegi.com/category/english/2012-07-21/pdf-half-way" />
        <updated>2012-07-21T00:00:00-07:00</updated>
        <id>http://blog.yeredusuncedernegi.com/category/english/2012-07-21/pdf-half-way</id>
        <content type="html">&lt;p&gt;The first half of the GSoC 2012 is over now. Since LibreOffice team set &amp;#8216;merging GSoC feature branch into master&amp;#8217; as a &lt;a href='http://nabble.documentfoundation.org/Libreoffice-qa-minutes-of-ESC-call-td3991620.html'&gt;requirement&lt;/a&gt; for the midterm, I have marked PDF Signing fature as &lt;a href='http://www.tuxmachines.org/images/libOpics/libO_experimentalmode.png'&gt;experimental feature&lt;/a&gt; and &lt;a href='http://cgit.freedesktop.org/libreoffice/core/commit/?id=9c8dc01d3a40ec905c9d816c733ceb5d621e0426'&gt;merged&lt;/a&gt; into master&lt;sup id='fnref:1'&gt;&lt;a href='#fn:1' rel='footnote'&gt;1&lt;/a&gt;&lt;/sup&gt;, and recently I have deleted my feature branch. From now on, I&amp;#8217;ll continue to work on the master.&lt;/p&gt;

&lt;p&gt;All changes I have made can be seen in the merge commit but let me explain what those commits mean in detail.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;First, I have added the Signature widget annotation type to &lt;code&gt;vcl/inc/vcl/pdfwriter.hxx&lt;/code&gt; and &lt;code&gt;vcl/source/gdi/pdfwriter_impl.cxx&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;emitSignature and finalizeSignature methods are added to PDFWriterImpl class. Those methods are called in &lt;code&gt;PDFWriterImpl::emit()&lt;/code&gt; which is the final operation of PDF creation, it writes all the prepared PDF structures to the given file in order. Page, resource, outline, catalog, annotations, metadata objects are all written to the PDF file in the emit method.&lt;/p&gt;

&lt;p&gt;At the beginning of the emit method, I have checked the PDFWriterContext to see if signing is requested&lt;sup id='fnref:2'&gt;&lt;a href='#fn:2' rel='footnote'&gt;2&lt;/a&gt;&lt;/sup&gt; and then create a Signature annotation object. Next, after the Catalog object is emitted, the main Signature objects (&lt;code&gt;/Type
/Sig&lt;/code&gt; and &lt;code&gt;/Type /SigRef&lt;/code&gt;) are emitted. But, unfortunately we have to include a byte range in the signature dictionary as well as the digest of that byte range. Since the document is not finalized yet (the last part is the Trailer in the PDF file.), we cannot specify a ByteRange and the document digest now. Instead, we write a dummy ByteRange value and a dummy signature and reserve a space to fill it later when the document is finalized. Of course, we have to write down the offset values of that dummy byte range and digest object, so we can fill them later on.&lt;/p&gt;

&lt;p&gt;Finally, when the trailer is emitted in the ::emit method, we are ready to fix the ByteRange values and include the digest value. This is what the finalizeSignature method does. finalizeSignature calculates the real ByteRange value and fix the old values. Next, reads the whole PDF data to create a PKCS7 object using NSS library. But since we don&amp;#8217;t have a certificate now (PDF export dialog has to be changed to make users select the certificate) PKCS7 object creation is not implemented.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;I have added a new &lt;a href='http://i.imgur.com/JVabH.png'&gt;Digital Signatures tab&lt;/a&gt; to the PDF export dialog&lt;sup id='fnref:3'&gt;&lt;a href='#fn:3' rel='footnote'&gt;3&lt;/a&gt;&lt;/sup&gt;. But this wasn&amp;#8217;t easy. First I thought that certificate selection dialog is used in &lt;a href='http://i.techrepublic.com.com/blogs/libreoffice_sigs.png'&gt;document signing&lt;/a&gt; and it must be easy to re-use it. But, that dialog (&lt;code&gt;xmlsecurity/source/dialogs/certificatechooser.cxx&lt;/code&gt;) seems to be an internal part of the xmlsecurity module and can only used in the signDocumentContent method of the &lt;a href='http://api.libreoffice.org/docs/common/ref/com/sun/star/security/XDocumentDigitalSignatures.html'&gt;XDocumentDigitalSignatures UNO interface&lt;/a&gt;. So, I had to extend that UNO interface and added a chooseCertificate method. It just asks user to choose a certificate and returns it. That&amp;#8217;s all. So, certificate chooser dialog can now be used in anywhere using the &lt;a href='http://cgit.freedesktop.org/libreoffice/core/tree/offapi/com/sun/star/security/XDocumentDigitalSignatures.idl#n148'&gt;&lt;code&gt;com::sun::star::security::XCertificate chooseCertificate();&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, to finalize the signed PDF document now I have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the document data to compute its digest,&lt;/li&gt;

&lt;li&gt;&lt;a href='http://en.wikipedia.org/wiki/Distinguished_Encoding_Rules'&gt;DER encoded&lt;/a&gt; certificate of the user,&lt;/li&gt;

&lt;li&gt;the password of the user to decrypt his private key and sign the digest.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also, I now the byte offset of digital signature to write the computed PKCS7 object. I hope, adding a few lines will be enough to complete signing :)&lt;/p&gt;

&lt;p&gt;Cheers.&lt;/p&gt;
&lt;div class='footnotes'&gt;&lt;hr /&gt;&lt;ol&gt;&lt;li id='fn:1'&gt;
&lt;p&gt;By the way, since I didn&amp;#8217;t use &lt;code&gt;--enable-werror&lt;/code&gt; configure option and ignored some warnings caused by my changes, I have broken some builds in the &lt;a href='http://tinderbox.libreoffice.org/MASTER/status.html'&gt;master tinderbox&lt;/a&gt;. Sorry about that :) Now I know, I must use &lt;code&gt;--enable-werror&lt;/code&gt; and &lt;code&gt;--enable-dbgutil&lt;/code&gt; all the time.&lt;/p&gt;
&lt;a href='#fnref:1' rev='footnote'&gt;&amp;#8617;&lt;/a&gt;&lt;/li&gt;&lt;li id='fn:2'&gt;
&lt;p&gt;As you know, &lt;a href='http://i43.tinypic.com/343gfhu.jpg'&gt;PDF export dialog&lt;/a&gt; has a great deal of options. This dialog, which resides in &lt;code&gt;filter/source/pdf/impdialog.cxx&lt;/code&gt;, basically takes all PDF export parameters and passes them to PDFFilter class and it forwards those parameters to PDFExport class. Finally, PDFExport class instantiate a PDFWriterContext object and pass it to the vcl::PDFWriter class. (I want to thank GDB to make this process easier to understand.)&lt;/p&gt;
&lt;a href='#fnref:2' rev='footnote'&gt;&amp;#8617;&lt;/a&gt;&lt;/li&gt;&lt;li id='fn:3'&gt;
&lt;p&gt;Right now, password box is an ordinary text edit. So be careful, your private key password will be exposed :) As a second matter, the design of the certificate selection is ugly. I may use the certificate selection design of &lt;a href='https://www.globalsign.com/support/personal-certificate/images/ps_thunderbird_screenshot4.jpg'&gt;Thunderbird&lt;/a&gt;. There are disabled text edit, a select and clear button. Thus, I can also remove Sign PDF File checkbox.&lt;/p&gt;
&lt;a href='#fnref:3' rev='footnote'&gt;&amp;#8617;&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;</content>
    </entry>
    
    <entry>
        <title>PDF signing GSoC roadmap</title>
        <link href="http://blog.yeredusuncedernegi.com/category/english/2012-06-08/pdf-gsoc-report" />
        <updated>2012-06-08T00:00:00-07:00</updated>
        <id>http://blog.yeredusuncedernegi.com/category/english/2012-06-08/pdf-gsoc-report</id>
        <content type="html">&lt;p&gt;Actually, I&amp;#8217;ve sent a mail about that roadmap but for those who didn&amp;#8217;t see it, here is the current progress in GSoC PDF signing project.&lt;/p&gt;

&lt;p&gt;After weeks of reading the PDF reference and inspecting the PortableSigner implementation, here is what I must do to implement signing support:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create an Annotation object of Widget subtype. Make it&amp;#8217;s width and height zero since we don&amp;#8217;t want to make the signature visible, for now. (Yes, digital signatures may be &lt;a href='http://www.tracker-software.com/knowledgebase/290-How-do-I-create-an-invisible-digital-certificate'&gt;visible&lt;/a&gt;. There is even a document about &lt;a href='http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/acrobat_digital_signature_appearances_v9.pdf'&gt;that&lt;/a&gt;.)&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Create and AcroForm field (/FT/Sig) as the parent of the Annotation object we created. Only buttons, combobox, listbox, edit and hierarchy is defined now.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Create a Signature dictionary (/Type/Sig). AcroForm field must point to that dictionary in the /V field. This is the crucial object. Prepare a PKCS#7 object and use it as the /Contents value. It must contain the X.509 certificate and the encrypted message digest.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Modify /Catalog object of the PDF document so that /AcroForm points to the our AcroForm field.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Modify the first /Page object so that it&amp;#8217;s /Annots key points to our Annotation object.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Write a new xref table and the final trailer.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That&amp;#8217;s all, it&amp;#8217;s very easy :) It seems most of these changes will be applied to vcl/source/gdi/pdfwriter_impl.{c,h}xx files.&lt;/p&gt;

&lt;p&gt;As &lt;a href='http://blog.thebehrens.net/'&gt;Thorsten&lt;/a&gt; said, I will mimic the behaviour of the &lt;a href='http://portablesigner.sourceforge.net/'&gt;PortableSigner&lt;/a&gt; tool first. PortableSigner use the incremental updating feature of the PDF. This feature allows pdf editing tools to edit PDF file by adding new or existing objects to the end of the file. So, if an object exists more than once, last occurence is used.&lt;/p&gt;

&lt;p&gt;In the PDF export code I have to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Add PDFWriter::SignatureWidget AcroForm type and use &lt;a href='http://opengrok.libreoffice.org/xref/core/vcl/source/gdi/pdfwriter_impl.cxx#11535'&gt;PDFWriterImpl::createControl()&lt;/a&gt; to add a Signature field.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Now, &lt;a href='http://opengrok.libreoffice.org/xref/core/vcl/source/gdi/pdfwriter_impl.cxx#5706'&gt;PDFWriterImpl::emitCatalog()&lt;/a&gt; method writes all the Pages, Resources and Catalog objects. I think I need to split those into different methods, so I can emit the modified catalog again.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Re-write the /Page object that contains recently added Signature annotation.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Add a new xref table and a new trailer at the end. I don&amp;#8217;t know how to implement that now. PDFWriterImpl::emitTrailer() method writes all objects but in incremental updates we must include only added/modified objects to the xref table.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I know that is a kind of &amp;#8220;note-to-self&amp;#8221; but I&amp;#8217;ve tried to write down all the steps that I can think of.&lt;/p&gt;</content>
    </entry>
    
    <entry>
        <title>A Short Introduction to PDF</title>
        <link href="http://blog.yeredusuncedernegi.com/category/english/2012-05-20/some-details-bout-pdf" />
        <updated>2012-05-20T00:00:00-07:00</updated>
        <id>http://blog.yeredusuncedernegi.com/category/english/2012-05-20/some-details-bout-pdf</id>
        <content type="html">&lt;p&gt;In this blog post, I&amp;#8217;ll try to summarize what I have learnt about PDF so far. I used the &lt;a href='http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf'&gt;ISO 32000-1:2008 document&lt;/a&gt; as a reference.&lt;/p&gt;

&lt;h3 id='standardization'&gt;Standardization&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;To make desktop printers able to render complex text and graphics files in a uniform way, PostScript page description language is created in 1985. Similarly, as a way to view these complex text and graphics files electronically in a platform independent manner, PDF is created by Adobe Systems company in 1992 under the name Project Camelot.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;PDF was originally a proprietary format controlled by Adobe. In 1993, the first complete PDF specification is published (PDF 1.0) by Adobe and this specification is free of charge since 2001. The last reference is the &lt;a href='http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf'&gt;PDF 1.7 file&lt;/a&gt; issued by Adobe.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;There are also some specialized and more restrictive subsets of PDF such as PDF/A (PDF for archive), PDF/X (PDF for exchange), PDF/E (PDF for engineering) etc. These subsets are released as ISO standards in 2001, 2005 and 2008 respectively. As I said, those are more restrictive file formats. For example, you may embed the fonts into a PDF file or not (more on that later). You are free to use external references for fonts, images, videos etc. (just like the HTML files). But if you are preparing a PDF/A compatible PDF file, you have to embed all the fonts you used. In PDF/A, the external content references are forbidden as well as audio/video content and encyption. Shortly; in these subsets, some PDF features that are not suited for some specific reasons (like archiving, exchange etc.) are left out.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Since 2008, PDF is an ISO standard, namely &lt;a href='http://www.iso.org/iso/catalogue_detail.htm?csnumber=51502'&gt;ISO 32000-1:2008&lt;/a&gt;. This standard is consistent with the PDF 1.7 which was the last PDF specification published by Adobe. Future versions of PDF will be published by the ISO technical commitees. But after ISO 32000-1, Adobe published &lt;a href='http://www.adobe.com/devnet/pdf/pdf_reference.html'&gt;some extensions&lt;/a&gt; to the ISO 32000-1:2008 standard and those extensions will be added in ISO 32000-2 which will be the PDF 2.0.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id='pdf_internals'&gt;PDF internals&lt;/h3&gt;

&lt;p&gt;Now, I want to mention about some interesting bits of the PDF:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;PDF files start with the %PDF-x.y marker stating which version of PDF the file comforms with. Even though the rest of the file is binary, all the keywords of the format (such as obj/endobj, stream/endstream or Named Objects like /Type, Length etc.) are ASCII strings. So, you can roughly have an idea about the structure of the document when you inspect the file with a text editor. But be careful about file editing! Since text editors may change/convert line endings, it&amp;#8217;s not recommended to edit PDF files with text editors.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Type 1, TrueType and OpenType fonts can be embedded to PDF files. If you want the document to be smaller, subset of a font may also be embedded. But whether you embed any fonts or not, PDF standard assumes that viewer applications can display 14 basic fonts such as Helvetica, Times, Courier etc. In the case that you refer to a non-standard font that is also not embedded, it&amp;#8217;s the responsibility of the viewer application to find those fonts in the environment. As you guess, this approach damages portability since users may not have the fonts used in the file.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;All the text, images, numbers, shapes and even the pages of the PDF document are represented as &amp;#8220;objects&amp;#8221; in PDF files. At the end of the each PDF file, there is a section called xref (read as the &amp;#8220;cross reference table&amp;#8221;), that keeps the byte offset of the objects from the start of the file to provide random access to all objects. xref is stored at the end of the file, so that the PDF creator applications can create a PDF file in a single pass. This also provides an efficient way to view the document, for example think about a document with thousands of pages, if a reader wants to render page 456, it can find that page quickly using the xref table. PDF files are read from the end of the file to get the xref table and object offsets.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Encryption and digital signing is possible in PDF. For password-based symmetric encryption; RC4 (proprietary algorithm of RSA) or AES (starting with PDF 1.6) algorithms are used with 40 or 128 bit keys. Actually, MD5 digest of the password is used as the key of RC4 or AES. Additionally, public key encyrption can used used with the combination of symmetric encryption. Basically; symmetric key that is used to encrypt the document is encrypted with the public key of a user. When that user gets the document, she first decrypts the symmetric key using her private key and then decrypts the document with the symmetric key. Moreover, you can define user-based access permissions such as user Ibrahim cannot print the document but can fill the forms, user Ozan can add annotations but cannot copy text etc. (I will tell the details about the digital signatures in the next post.)&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;PDF files may contain interactive forms fields (such as push buttons, radio buttons, checkboxes etc.) to gather information interactively from the user. You can also define an Action and associate that action with a form element (like a button). So it&amp;#8217;s possible to play a sound, submit form values to a URL, reset form fields, interpret JavaScript code, launch an application etc. when a button is pressed. I know, JavaScript seems interesting, but for example it&amp;#8217;s possible to modify the appearence of the PDF file using JavaScript. &lt;a href='http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf'&gt;Here&lt;/a&gt; is the JavaScript API defined by Adobe.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Compression of the objects (text, images etc.) are supported. So, you can compress your images using JPEG, JPEG2000, CCITT and JBIG2 while you can use LZW or Flate for text, graphics or images.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Incremental updates: PDF allows modifications to be appended to the end of the file. This appended part only contains the modified objects in the PDF file. In this way, you don&amp;#8217;t have to load the whole document and rewrite all parts of the document each time it&amp;#8217;s saved. For example, when you digitally sign the document using a tool (such as &lt;a href='http://portablesigner.sourceforge.net'&gt;PortableSigner&lt;/a&gt;, you can see that only some new objects including /Sig and /SigRef dictionaries are stored at the end of the file.&lt;/p&gt;

&lt;p&gt;Another advantage of this method is the possibility of undoing changes. Since the original document is preserved, it&amp;#8217;s easy to render it.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That&amp;#8217;s it for today.&lt;/p&gt;</content>
    </entry>
    
    <entry>
        <title>GSoC 2012 - Introduction</title>
        <link href="http://blog.yeredusuncedernegi.com/category/english/2012-05-14/gsoc-introduction-and-pdf" />
        <updated>2012-05-14T00:00:00-07:00</updated>
        <id>http://blog.yeredusuncedernegi.com/category/english/2012-05-14/gsoc-introduction-and-pdf</id>
        <content type="html">&lt;h2 id='a_short_introduction'&gt;A Short Introduction&lt;/h2&gt;

&lt;p&gt;Firstly, let me introduce myself. My name is Gökçen Eraslan, I&amp;#8217;m a FLOSS developer and Computer Science M.S. student in Bogazici University of Turkey. Previously I worked for TUBITAK (The Scientific and Technological Research Council of Turkey, equivalent of NSF in Turkey) for 4 years. I was a developer and the release manager of the &lt;a href='http://www.pardus.org.tr/en'&gt;Pardus Linux distribution project&lt;/a&gt; which is a government funded project aiming to develop a mature Linux distribution along with technological innovations (a brand new package manager, installer, configuration system etc.) as well as encouraging free software development in Turkey in order to avoid the massive sums needed for the license fees of proprietary operating systems. But lately Pardus project is somehow suspended (details &lt;a href='http://developer.pardus.org.tr/people/ozan/blog/?p=144'&gt;here&lt;/a&gt;) and most of the core developers left Pardus.&lt;/p&gt;

&lt;h2 id='gsoc_2012'&gt;GSoC 2012&lt;/h2&gt;

&lt;p&gt;I have been selected as one of the &lt;a href='http://www.google-melange.com/gsoc/org/google/gsoc2012/libreoffice'&gt;GSoC 2012 students&lt;/a&gt; of the LibreOffice project. My GSoC proposal is to add digital signing support to PDF export feature. This is an idea from &lt;a href='http://wiki.documentfoundation.org/Development/Gsoc/Ideas#Sign_PDF_documents_on_export'&gt;The Document Foundation ideas page&lt;/a&gt;. Although I&amp;#8217;ve fixed a python-based &lt;a href='https://bugs.freedesktop.org/show_bug.cgi?id=46538'&gt;LibreOffice easyhack&lt;/a&gt;, I&amp;#8217;m not experienced in LibreOffice codebase. But since the document signing (not PDF signing) is already supported by LibreOffice, I hope certificate management (such as listing and choosing certificates provided from the certificate database of Mozilla applications) will be easy using the existing classes.&lt;/p&gt;

&lt;p&gt;Right now, I&amp;#8217;m reading &lt;a href='http://www.adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf'&gt;ISO 32000-1:2008 PDF standard&lt;/a&gt; and my next planned step is to be familiar with PKCS#1, PKCS#7 and PKCS#12 standards and to learn code pointers to PDF export code in LibreOffice.&lt;/p&gt;

&lt;h2 id='tools_and_frameworks_for_pdf_signing_in_linux'&gt;Tools and Frameworks for PDF Signing in Linux&lt;/h2&gt;

&lt;p&gt;I am also looking for the ways of signing PDF files digitally in Linux. So, I can look at some real world examples about PDF signing and compare the documents signed by LibreOffice and those tools. Here are popular PDF signing tools and frameworks that I found:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href='http://portablesigner.sourceforge.net/'&gt;PortableSigner&lt;/a&gt;: Best known PDF signing tool in Linux which is written in Java and licensed under &lt;a href='http://joinup.ec.europa.eu/software/page/eupl'&gt;EUPL&lt;/a&gt;. PortableSigner provides both CLI and GUI tools and requires your PKCS#12 file (containing your private key) and an X.509 certificate file (that authorizes you) to sign a PDF file. (In my next blog entry I want to briefly explain how digital signatures work.)&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;&lt;a href='http://itextpdf.com/'&gt;iText&lt;/a&gt;: Best known PDF framework also written in Java and licensed under AGPL. There is a C# port called iTextSharp as well. This framework implements various classes to generate PDF files as well as the classes to update PDF files. So it&amp;#8217;s can split, merge, sign and encrypt PDF files. Actually, iText is the crucial component of many known PDF tools including PortableSigner, &lt;a href='http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/'&gt;pdftk&lt;/a&gt; etc.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Proprietary tools such as &lt;a href='http://get.adobe.com/reader/'&gt;Adobe Reader&lt;/a&gt;, &lt;a href='http://www.kryptokoder.com/index.html'&gt;myPDFSigner&lt;/a&gt; or &lt;a href='http://www.qoppa.com/pdfstudio/'&gt;PDF Studio Pro&lt;/a&gt; can also sign PDF files. I tried Adobe Reader but I couldn&amp;#8217;t make it work under Linux due to the 32-64 bit library problems. (It requires 32-bit libxul.so and crashes with SIGSEGV when I point it to that library.) Anyway, I think the only benefit of Adobe Reader will be that I can use it to verify my signed PDF files.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That&amp;#8217;s it for today.&lt;/p&gt;</content>
    </entry>
    
</feed>
