Open Source eID Projects RMLL Frank Cornelis 10/07/2013
Agenda ● Overview eID ● Cryptography in Java via JCA ● RSA, PKI, jTrust, eID Trust Service ● Integration levels for eID ● eID Applet ● Commons eID ● eID Identity Provider ● eID Digital Signature Service
eID Functionality ● Identification – Who are you? ● Authentication – Can you prove who you are? ● Digital signatures – Proof of statement made in time
The Belgian eID Card Physical Structure Logical Structure APDU eID Card Crypto ROM Belgian eID Card JavaCard Applet (RSA) (operating system) JavaCard Virtual Machine EEPROM (file system) Basic Operating System CPU Infineon Chip (SLE66CX322P) RAM (memory)
eID Card Content PKI Citizen Identity Data Authentication Photo RSA key + Cert Non-repudiation RSA key + Cert Identity File Identity File NRN Signature Root CA Certificate Address File Address File Citizen CA NRN Signature Certificate NRN PKCS#15 file structure Certificate
Cryptography ● Encryption/decryption – Symmetric: AES – Asymmetric: RSA ● Digital signatures – RSA ● Hash functions – SHA256 ● MAC ● Threshold crypto ● ...
Symmetric encryption K Hello world E #%f8kdi%d D Hello world KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); keyGenerator.init(128); SecretKey secretKey = keyGenerator.generateKey(); byte[] message = "hello world".getBytes(); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, secretKey); byte[] encryptedMessage = cipher.doFinal(message); cipher.init(Cipher.DECRYPT_MODE, secretKey); byte[] result = cipher.doFinal(encryptedMessage);
Asymmetric encryption G K K Hello world E #%f8kdi%d D Hello world KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); keyPairGenerator.initialize(1024); KeyPair keyPair = keyPairGenerator.genKeyPair(); byte[] message = "hello world".getBytes(); Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.ENCRYPT_MODE, keyPair.getPublic()); byte[] encryptedMessage = cipher.doFinal(message); cipher.init(Cipher.DECRYPT_MODE, keyPair.getPrivate()); byte[] result = cipher.doFinal(encryptedMessage);
Hash Functions Hello world H #%f8kdi%d Another message H byte[] message = "hello world".getBytes(); MessageDigest messageDigest = MessageDigest.getInstance("SHA256"); messageDigest.update(message); byte[] result = messageDigest.digest();
Digital Signatures G K K Hello world S #%f8kdi%d V true/false KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); keyPairGenerator.initialize(1024); KeyPair keyPair = keyPairGenerator.genKeyPair(); byte[] message = "hello world".getBytes(); Signature signature = Signature.getInstance("SHA1withRSA"); signature.initSign(keyPair.getPrivate()); signature.update(message); byte[] signatureValue = signature.sign(); signature.initVerify(keyPair.getPublic()); signature.update(message); boolean result = signature.verify(signatureValue);
RSA ∣ G ∣ = e G ⇒ a t ∣ G ∣+ 1 = a group 〈 G , ∘〉 : ∀ a ∈ G : a n = pq ( Miller-Rabin ) ∗ ={ a ∈ℤ n : a ⊥ n } is a group ℤ n ∗ ∣=ϕ( n )=( p − 1 )( q − 1 ) ∣ℤ n e ⊥ϕ( n )⇒∃ d : ed ≡ 1 ( mod ϕ( n )) + =〈 e,n 〉 public key: K − =〈 d ,n 〉 private key : K ∗ : c ≡ a e ( mod n ) ∀ a ∈ℤ n d ≡( a e ) d ≡ a t ϕ( n )+ 1 ≡ a ( mod n ) ⇒ c with cipher text c
PKCS#1 ● Textbook RSA has some problems: – Common modulus – Blinding – Low public exponent ● PKCS#1 introduces padding, ... ● 00 01 ff ff ff ... ff ff ff 00 DigestInfo(OID, #) RSAPublicKey publicKey = (RSAPublicKey) certificate.getPublicKey(); BigInteger signatureValueBigInteger = new BigInteger(signatureValue); BigInteger messageBigInteger = e ( mod n ) c signatureValueBigInteger.modPow( publicKey.getPublicExponent(), publicKey.getModulus());
ASN.1 & DER ● Abstract Syntax Notation One FullName ::= SEQUENCE { Name IA5String GivenName IA5String } ● Distinguished Encoding Rules 30 0a 16 3 “f” “o” “o” 16 3 “b” “a” “r” ● Implementation: BouncyCastle
PKI K K K K ? CA signs K X509 certificate K K begin, end key purpose ...
Certificate Life Cycle ? Key generation K CSR Certificate Suspended Valid Revoked Expired
Certificate Status ● CRL: Certificate Revocation List – Contains serial numbers of revoked certs – Signed by the CA – Issued periodically ● Online Certificate Status Protocol – Online query for certificate status – Signed by the CA OCSP Responder
eID PKI Infrastructure GlobalSign CA Cert Root CA Cert same key Root CA Cert CRL Citizen CA Cert Gov CA Cert OCSP Responder CRL CRL eID Cert SSL Cert
X509 Validation: jTrust ● Alternative to Java Cert Path API ● Java library with flexible architecture ● Readable code Certificate[] authnCertificateChain = ... Security. addProvider ( new BouncyCastleProvider()); TrustValidator trustValidator = BelgianTrustValidatorFactory. createTrustValidator (); trustValidator.isTrusted(authnCertificateChain);
jTrust Architecture Root CA CRL Set of Trust Points Public Key Trust Linker Certificate Repository CRL Trust Linker CRL Repo Trust List of Trust Linkers OCSP Trust Linker OCSP Repo Validator List of Cert Constraints Fallback Trust Linker eID Trust Service CRL Cache Trust Linker OCSP Responder
X509 Validation: jTrust
X509 Validation: Trust Service ● jTrust extension: CRL cache (Java EE) ● XKMS2 web service interface ● Java SDK List<X509Certificate> authnCertificateChain = ... XKMS2Client client = new XKMS2Client( "https://www.e-contract.be/eid-trust-service-ws/xkms2"); client.validate("BE-AUTH", authnCertificateChain);
eID Trust Service Architecture SOAP XKMS Web Portal Relying Party Belgian Applications Citizen Trust Service Model CRL Cache DBMS Admin Portal jTrust eID TSL Tool PKI TSL Trust Service OCSP CRL Admin Service Directive CA EC
X509 Validation: Trust Service
Bootstrapping Trust ● Trusted Lists & List of Trusted Lists (LoTL) ● Dynamic updating of the EU trust realm ● Bootstrapping reduced to a single key LoTL EC LoTL Signing Key BE TL NL TL … TL Root CA Root CA2 ...
Trusted List Belgium
eID Web Integration authentication identification signatures SSL IdP DSS Applet Middleware PC/SC CCID USB Smart card reader eID
eID Desktop Integration authentication identification signatures PKCS#11 Commons eID Middleware PC/SC CCID USB Smart card reader eID
PC/SC TerminalFactory terminalFactory = TerminalFactory. getDefault (); CardTerminals cardTerminals = terminalFactory.terminals(); CardTerminal cardTerminal = cardTerminals.list().get(0); Card card = cardTerminal.connect("T=0"); CardChannel cardChannel = card.getBasicChannel(); // select file cardChannel.transmit( new CommandAPDU(0x00, 0xA4, 0x08, 0x0C, new byte [] { 0x3F, 0x00, ( byte ) 0xDF, 0x01, 0x40, 0x35 })); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int offset = 0; ResponseAPDU responseApdu; do { // read binary responseApdu = cardChannel.transmit( new CommandAPDU(0x00, 0xB0, offset >> 8, offset & 0xFF, 0xff)); baos.write(responseApdu.getData()); offset += responseApdu.getData().length; } while (responseApdu.getData().length == 0xff); BufferedImage photo = ImageIO. read ( new ByteArrayInputStream(baos.toByteArray())); JOptionPane. showMessageDialog ( null , new ImageIcon(photo));
eID Applet Web Browser Web Container 1 Web Page 3 eID Applet eID Applet SPI Service 2 4 5 3 HTTP Session Target Page Service Implementation jTrust 6 ● eID Applet Service targets Java EE servlet container only
eID Applet Example identify-the-user.html <script src= "https://www.java.com/js/deployJava.js" ></script> <script> var attributes = { code :'be.fedict.eid.applet.Applet.class', archive :'eid-applet-package-1.1.0.Beta4.jar', width :600, height :300 }; var parameters = { TargetPage :'identification-result-page.jsp', AppletService :'applet-service', }; var version = '1.6'; identification-result-page.jsp deployJava.runApplet(attributes, parameters, version); </script> <%@page import= "be.fedict.eid.applet.service.Identity" %> <html> <body> <%=((Identity) session.getAttribute("eid.identity")).name%> </body> </html> web.xml <servlet> <servlet-name>AppletServiceServlet</servlet-name> <servlet-class>be.fedict.eid.applet.service.AppletServiceServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>AppletServiceServlet</servlet-name> <url-pattern>/applet-service</url-pattern> </servlet-mapping>
eID Applet
eID Applet
Commons eID eID MW 3.5 eID MW 4.0 eID Applet eID Viewer Commons eID eID Viewer 2.0 eID Applet 2.0 JCA
Commons eID Components commons-eid-client commons-eid-dialogs commons-eid-jca commons-eid-consumer ● Desktop: commons-eid-jca, or lower-level ● Client-Server: – Client: commons-eid-client, dialogs – Server: commons-eid-consumer
Recommend
More recommend