PAdES signatures in itext and the road ahead. Paulo Soares



Similar documents
ETSI TS V1.1.1 ( ) Technical Specification

ETSI TS V1.1.2 ( ) Technical Specification

TechNote 0006: Digital Signatures in PDF/A-1

Digital Signature Service. version : 4.7-SNAPSHOT

In accordance with article 11 of the Law on Electronic Signature (Official Gazette of the Republic of Serbia No. 135/04), REGULATION

ETSI TS V1.1.1 ( ) Technical Specification

Digital Signature Service. version :

ETSI TS V1.1.1 ( ) Technical Specification

Specifying the content and formal specifications of document formats for QES

Digital Signatures in a PDF

Multiple electronic signatures on multiple documents

White Paper. Digital signatures from the cloud Basics and Applications

ETSI SECURITY WEEK EIDAS Overview CEN/ETSI esignature Standardization including standards for TSP Compliance. ETSI All rights reserved

ETSI TS V1.1.1 ( ) Technical Specification

Representation of E-documents in AIDA Project

Electronic Signature. István Zsolt BERTA Public Key Cryptographic Primi4ves

PkBox Technical Overview. Ver

.NET Digital Signature Library User Manual

Best prac*ces in Cer*fying and Signing PDFs

How to Time Stamp PDF and Microsoft Office 2010/2013 Documents with the Time Stamp Server

Submitted to the EC on 03/06/2012. COMPETITIVENESS AND INNOVATION FRAMEWORK PROGRAMME ICT Policy Support Programme (ICT PSP) e-codex

Certificate Path Validation

Digital Signature Verification using Historic Data

Long term electronic signatures or documents retention

e-szigno Digital Signature Application

2.1 The scope of Time Stamping Protocol (TSP)

Exploring ADSS Server Signing Services

CERTIFICATION PRACTICE STATEMENT UPDATE

Technical Description. DigitalSign 3.1. State of the art legally valid electronic signature. The best, most secure and complete software for

CALIFORNIA SOFTWARE LABS

Digital Signature Service. e-contract.be BVBA 2 september 2015

Package PKI. February 20, 2013

NISTIR 7676 Maintaining and Using Key History on Personal Identity Verification (PIV) Cards

FOR A PAPERLESS FUTURE. Petr DOLEJŠÍ Senior Solution Consultant SEFIRA Czech Republic

ETSI TR V0.0.3 ( )

Certification Authority. The X.509 standard, PKI and electronic documents. X.509 certificates. X.509 version 3. Critical extensions.

Digital Signature: Efficient, Cut Cost and Manage Risk. Formula for Strong Digital Security

Entrust Certificate Services. Java Code Signing. User Guide. Date of Issue: December Document issue: 2.0

NEMA Standards Publication PS 3 Supplement 41. Digital Imaging and Communications in Medicine (DICOM) Digital Signatures

The Direct Project. Implementation Guide for Direct Project Trust Bundle Distribution. Version March 2013

Biometrics, Tokens, & Public Key Certificates

SSO Eurécia. and external Applications. Purpose

ETSI TS V1.4.2 ( ) Technical Specification. Electronic Signatures and Infrastructures (ESI); XML Advanced Electronic Signatures (XAdES)

PDF Signer User Manual

mod_ssl Cryptographic Techniques

Open Source eid Projects

STANDARDISIERUNG FÜR EIDAS IM MANDATE/460

ETSI TS V1.1.1 ( )

NIST-Workshop 10 & 11 April 2013

ETSI TS V1.1.1 ( ) Technical Specification

Package PKI. July 28, 2015

BDOC FORMAT FOR DIGITAL SIGNATURES

Digital Signing without the Headaches

<Insert Picture Here> Oracle Security Developer Tools (OSDT) August 2008

LinShare project version 0.8 File sharing and vault application

Signature policy for TUPAS Witnessed Signed Document

Cryptography and Network Security Chapter 15

DIGITAL SIGNATURE FOR EANCOM MESSAGES

ETSI TS V1.3.2 ( )

PEXA Public Key Infrastructure (PKI) Certification Authority Certificate Policy

Detailed Specifications

I N F O R M A T I O N S E C U R I T Y

X.500 and LDAP Page 1 of 8

SAFE Digital Signatures in PDF

I N F O R M A T I O N S E C U R I T Y

ATSC Standard: ATSC Security and Service Protection Standard

CS 393 Network Security. Nasir Memon Polytechnic University Module 11 Secure

DEPARTMENT OF DEFENSE PUBLIC KEY INFRASTRUCTURE EXTERNAL CERTIFICATION AUTHORITY MASTER TEST PLAN VERSION 1.0

BERserk Vulnerability

Alternate Representations of the Public Key Cryptography Standards (PKCS) Using S-Expressions, S-PKCS

PKI - current and future

DIRECTOR GENERAL OF THE LITHUANIAN ARCHIVES DEPARTMENT UNDER THE GOVERNMENT OF THE REPUBLIC OF LITHUANIA

Paper-based Document Authentication using Digital Signature and QR Code

OpenADR 2.0 Security. Jim Zuber, CTO QualityLogic, Inc.

Guidelines for Developing Cryptographic Service Providers (CSPs) for Acrobat on Windows

Operating a CSP in Switzerland or Playing in the champions league of IT Security

Electronic Mail Security. Security. is one of the most widely used and regarded network services currently message contents are not secure

Technical Specification Electronic Signatures and Infrastructures (ESI); ASiC Baseline Profile

Lecture 9: Application of Cryptography

Additional Information. OpenLimit Middleware Version 3 Server Product Version: 1.2 Help Manual. Date: Document version: 1.

Crittografia e sicurezza delle reti. Digital signatures- DSA

Communication Security for Applications

Network Security Essentials Chapter 7

Interoperability Guidelines for Digital Signature Certificates issued under Information Technology Act

Electronic Archive Information System

Randomized Hashing for Digital Signatures

OFFICE OF THE CONTROLLER OF CERTIFICATION AUTHORITIES TECHNICAL REQUIREMENTS FOR AUDIT OF CERTIFICATION AUTHORITIES

Transcription:

PAdES signatures in itext and the road ahead Paulo Soares

About the speaker Paulo Soares M.Sc. Electronics and Telecomunications Hardware background in military comunication systems Works for www.glintt.com Healthcare software (pharmacies, hospitals, clinics, laboratories) Industrial control, automation Software architect itext co-developer since 2000 2012-03-29 itext Summit 2

Some acronyms OSI - Open Systems Interconnection ASN.1 - Abstract Syntax Notation One BER - Basic Encoding Rules DER - Distinguished Encoding Rules IETF - Internet Engineering Task Force RFC Request For Comments CMS Cryptographic Message Syntax CAdES - CMS Advanced Electronic Signatures PAdES - PDF Advanced Electronic Signature Profiles 2012-03-29 itext Summit 3

What is PAdES In July 2009, ETSI (European Telecommunications Standard Institute) has published a new standard that will facilitate secure paperless transactions throughout Europe, in conformance with European legislation. The standard defines a series of profiles for PAdES Advanced Electronic Signatures for PDF documents that meet the requirements of the European Directive on a Community framework for electronic signatures (Directive 1999/93/EC). The new standard was developed by ETSI's Electronic Signatures and Infrastructure (ESI) Technical Committee in collaboration with PDF experts. PDF is defined in a standard ISO 32000-1, so the ETSI activity included reviewing and documenting how ISO 32000-1 can satisfy the European Directive. The resulting PAdES standard, ETSI Technical Specification (TS) 102 778, also introduces a number of adaptations and extensions to PDF to satisfy the Directive's requirements. 2012-03-29 itext Summit 4

PAdES summary Part 1: "PAdES Overview - a framework document for PAdES"; Part 2: "PAdES Basic - Profile based on ISO 32000-1"; Part 3: "PAdES Enhanced - PAdES-BES and PAdES-EPES Profiles"; Part 4: "PAdES Long Term - PAdES-LTV Profile"; Part 5: "PAdES for XML Content - Profiles for XAdES signatures". 2012-03-29 itext Summit 5

PAdES Part 1 Provides a general description of support for signatures in PDF documents including use of XML signatures to protect XML data in PDF documents; Lists the features of the PDF profiles specified in other parts of the document; Describes how the profiles may be used in combination. 2012-03-29 itext Summit 6

PAdES Part 2 Profiles the use of PDF signatures, as described in ISO 32000-1 and based on CMS, for its use in any application areas where PDF is the appropriate technology for exchange of digital documents including interactive forms. 2012-03-29 itext Summit 7

PAdES Part 2 SubFilter value adbe.pkcs7.detached adbe.pkcs7.sha1 adbe.x509.rsa.sha1a Message Digest SHA1 (PDF 1.3) SHA256 (PDF 1.6) SHA384 (PDF 1.7) SHA512 (PDF 1.7) RIPEMD160 (PDF 1.7) SHA1 (PDF 1.3)b SHA1 (PDF 1.3) SHA256 (PDF 1.6) SHA384 (PDF 1.7) SHA512 (PDF 1.7) RIPEMD160 (PDF 1.7) RSA Algorithm Support Up to 1024-bit (PDF 1.3) Up to 2048-bit (PDF 1.5) Up to 4096-bit (PDF 1.5) See adbe.pkcs7.detached See adbe.pkcs7.detached DSA Algorithm Support Up to 4096-bits (PDF 1.6) See adbe.pkcs7.detached No a Despite the appearance of sha1 in the name of this SubFilter value, supported encodings shall not be limited to the SHA1 algorithm. The PKCS#1 object contains an identifier that indicates which algorithm shall be used. b Other digest algorithms may be used to digest the signed-data field; however, SHA1 shall be used to digest the data that is being signed. 2012-03-29 itext Summit 8

PAdES Part 3 Profiles the use of PDF Signatures specified in ISO 32000-1 with an alternative signature encoding to support signature formats equivalent to the signature forms CAdES-BES, CAdES-EPES and CAdES-T as Specified in TS 101 733. The PAdES-BES profile supports basic CMS (RFC 3852) signature features as specified TS 102 778-2 with the additional protection against signing certificate substitution. The PAdES-EPES profile extends the PAdES-BES profile to include signature policies. 2012-03-29 itext Summit 9

PAdES Part 4 Profiles the electronic signature formats found in ISO 32000-1 [1] to support Long Term Validation (LTV) of PDF Signatures Specifies how to include validation information in a PDF Document and to further protect the document using time-stamps so that it is possible to subsequently verify a PDF Signature long after it was signed. This profile may be used to support long term validation of: PDF Signatures to profiles specified in TS 102 778-2 PDF Signatures to profiles specified in TS 102 778-3 PDF Signatures to profiles specified in TS 102 778-5 2012-03-29 itext Summit 10

PAdES Part 4 2012-03-29 itext Summit 11

PAdES Part 5 Defines four profiles that together profile the usage of XAdES signatures, as defined in TS 101 903, for signing XML content within the PDF containers. 2012-03-29 itext Summit 12

PAdES support in itext Full support of PAdES Part 2 Support of PAdES Part 3 with an external signature Full support of PAdES Part 4 No support of PAdES Part 5 2012-03-29 itext Summit 13

PAdES Part 2 in itext Direct support of adbe.x509.rsa.sha1 Direct support of adbe.pkcs7.sha1 Support of adbe.pkcs7.detached as an external signature but itext does the signing 2012-03-29 itext Summit 14

adbe.x509.rsa.sha1 signing KeyStore ks = KeyStore.getInstance("pkcs12"); ks.load(new FileInputStream("my_private_key.pfx"), "my_password".tochararray()); String alias = (String)ks.aliases().nextElement(); PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".tochararray()); Certificate[] chain = ks.getcertificatechain(alias); PdfReader reader = new PdfReader("original.pdf"); FileOutputStream fout = new FileOutputStream("signed.pdf"); PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0'); PdfSignatureAppearance sap = stp.getsignatureappearance(); sap.setcrypto(key, chain, null, PdfSignatureAppearance.SELF_SIGNED); sap.setreason("i'm the author"); sap.setlocation("lisbon"); sap.setvisiblesignature(new Rectangle(100, 100, 200, 200), 1, null); stp.close(); 2012-03-29 itext Summit 15

adbe.pkcs7.sha1 signing KeyStore ks = KeyStore.getInstance("pkcs12"); ks.load(new FileInputStream("my_private_key.pfx"), "my_password".tochararray()); String alias = (String)ks.aliases().nextElement(); PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".tochararray()); Certificate[] chain = ks.getcertificatechain(alias); PdfReader reader = new PdfReader("original.pdf"); FileOutputStream fout = new FileOutputStream("signed.pdf"); PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0'); PdfSignatureAppearance sap = stp.getsignatureappearance(); sap.setcrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED); sap.setreason("i'm the author"); sap.setlocation("lisbon"); sap.setvisiblesignature(new Rectangle(100, 100, 200, 200), 1, null); stp.close(); 2012-03-29 itext Summit 16

adbe.pkcs7.detached signing PdfSignatureAppearance sap = stp.getsignatureappearance(); sap.setcrypto(null, chain, null, PdfSignatureAppearance.SELF_SIGNED); PdfSignature dic = new PdfSignature(PdfName.ADOBE_PPKLITE, new PdfName("adbe.pkcs7.detached")); dic.setdate(new PdfDate(sap.getSignDate())); sap.setcryptodictionary(dic); HashMap<PdfName,Integer> exc = new HashMap<PdfName,Integer>(); exc.put(pdfname.contents, new Integer(contentEstimated * 2 + 2)); sap.preclose(exc); PdfPKCS7 sgn = new PdfPKCS7(pk, chain, null, "SHA1", null, false); InputStream data = sap.getrangestream(); MessageDigest messagedigest = MessageDigest.getInstance("SHA1"); byte buf[] = new byte[8192]; int n; while ((n = data.read(buf)) > 0) messagedigest.update(buf, 0, n); byte hash[] = messagedigest.digest(); Calendar cal = Calendar.getInstance(); TSAClient tsc = new TSAClientBouncyCastle(TSA_URL, TSA_ACCNT, TSA_PASSW); byte[] ocsp = new OcspClientBouncyCastle((X509Certificate)chain[0], (X509Certificate)chain[1], url).getencoded(); byte sh[] = sgn.getauthenticatedattributebytes(hash, cal, ocsp); sgn.update(sh, 0, sh.length); byte[] encodedsig = sgn.getencodedpkcs7(hash, cal, tsc, ocsp); byte[] paddedsig = new byte[contentestimated]; System.arraycopy(encodedSig, 0, paddedsig, 0, encodedsig.length); PdfDictionary dic2 = new PdfDictionary(); dic2.put(pdfname.contents, new PdfString(paddedSig).setHexWriting(true)); sap.close(dic2); 2012-03-29 itext Summit 17

PAdES Part 3 in itext No direct support but possible to use an external signature itext currently has no capabilities to assist in the signing 2012-03-29 itext Summit 18

PAdES Part 4 in itext Full LTV support both in Document security Store and Timestamp 2012-03-29 itext Summit 19

PAdES Part 4 in itext PdfReader r = new PdfReader(IN_FILE); FileOutputStream fout = new FileOutputStream(OUT_FILE); PdfStamper stp = PdfStamper.createSignature(r, fout, '\0', null, true); LtvVerification v = stp.getltvverification(); AcroFields af = stp.getacrofields(); for (String signame : af.getsignaturenames()) { v.addverification(signame, new OcspClientBouncyCastle(), new CrlClientImp(), LtvVerification.CertificateOption.WHOLE_CHAIN, LtvVerification.Level.OCSP_CRL, LtvVerification.CertificateInclusion.NO); } PdfSignatureAppearance sap = stp.getsignatureappearance(); TSAClientBouncyCastle tsa = new TSAClientBouncyCastle(TSA_URL, TSA_ACCNT, TSA_PASSW, 6500, "sha256"); LtvTimestamp.timestamp(sap, tsa, null); 2012-03-29 itext Summit 20

itext sign architecture Certificate encryption Validation AcroFields.verifySignature() Signing PdfSignatureAppearance, PdfPKCS7 Open Source Modify at will 2012-03-29 itext Summit 21

Shortcomings of itext signing architecture Monolithic Impossible to open a certificate encrypted PDF with a smartcard with C# Impossible to plug-in another validation engine/logic Arbitrary signing is possible with an external signature but itext won t assist much in the process Open Source no urgency in providing a decent interface 2012-03-29 itext Summit 22

New itext signing architecture Based on the factory pattern Plug-in for certificate encryption, validation and signing Standard plug-in for detached signing and CAdES signing 2012-03-29 itext Summit 23