Sie sind auf Seite 1von 6

Class Outline

• What is security?
• Web security
Programming Mobile Devices
• XML and Web services security
Security • Security in Java, MIDP

Jacek Kopecký
jacek.kopecky@deri.org

What is Security? Authentication


• Authentication, authorization • Identifying the peer
• “Alice makes sure that she’s talking to Bob, not someone
• Confidentiality, privacy else”
• Non-repudiation • Physical authentication:
• Intrusion prevention, detection • Something Bob knows
• Password, PIN
• Risk assessment • Something Bob has
• ID smart card, cell phone
• Something Bob is
• Signature, fingerprint, retinal scan, voiceprint
• Digital authentication:
• Secure key, certificate

Confidentiality, Privacy,
Authorization
Non-repudiation
• Authorization – giving access to peer • Alice wants to send something to Bob, nobody else
• “Alice allows Bob to do certain things” • Revealing as little as possible from communication
to eavesdroppers
• Authenticated (known) peer • Private channel – hides data (usually encryption)
• Allowing or blocking an action • Various levels
• In a bank – access to your account, not others • Encrypted channel from you to mail server
• Encrypted email body, open headers
• Authorization requires authentication
• Privacy goes further
• Anonymizer proxy – hides user identity, behavior
• Non-repudiation
• Alice cannot deny sending something to Bob (digsig)
• Auditing, contracting

1
Intrusion prevention, detection
Web Security Overview
Risk assessment
• Security breaches • HTTP Authentication
• Viruses, worms, trojans etc. • HTTPS

1. Writing secure systems • Solutions for confidentiality, authentication


2. Logging significant actions (safely)
3. Auditing systems, logs

• What level of prevention is cheaper than


having breach?

Web Security – HTTP Auth Web Security – HTTPS


• Basic – almost plain text password • Confidentiality
• Digest – challenge, response • HTTPS provides TLS encryption
• Both are HTTP request parameters • Server authentication (important)
• Port 443 (not 80)
• Forms with username, password • Limits caching
• Forms can scramble the data on client • Supported in MIDP 2.0
• Part of payload on request

XML & WS Security Overview XML Encryption


• XML Encryption • Problem: hide parts of XML documents
• XML Digital Signature
• Includes XML Canonicalization <PaymentInfo xmlns='http://example.org/paymentv2'>
<Name>John Smith</Name>
• XML Key Management System <CreditCard Limit='5,000' Currency='USD'>
• Security Assertion, Access Control Markup <Number>4019 2445 0277 5567</Number>
• WS-Security <Issuer>Example Bank</Issuer>
<Expiration>04/02</Expiration>
</CreditCard>
</PaymentInfo>

2
XML Encryption XML Encryption
Hiding Whole XML Documents Hiding Elements
<EncryptedData <PaymentInfo xmlns='http://example.org/paymentv2'>
xmlns='http://www.w3.org/2001/04/xmlenc#'> <Name>John Smith</Name>
<CipherData> <EncryptedData
<CipherValue>A23B45C56</CipherValue> Type='http://www.w3.org/2001/04/xmlenc#Element'
</CipherData> xmlns='http://www.w3.org/2001/04/xmlenc#'>
</EncryptedData> <CipherData>
<CipherValue>A23B45C56</CipherValue>
</CipherData>
</EncryptedData>
</PaymentInfo>

XML Encryption
XML Signature
Hiding Element Content
<PaymentInfo xmlns='http://example.org/paymentv2'> • Digest of data, protected with encryption
<Name>John Smith</Name>
<CreditCard Limit='5,000' Currency='USD'> • Creating digital signature (roughly):
<EncryptedData xmlns='http://www.w3.org/2001/04/xmlenc#' • Digest the data
Type='http://www.w3.org/2001/04/xmlenc#Content'>
<CipherData>
• Encrypt the digest (with private or shared key)
<CipherValue>A23B45C56</CipherValue> • The encrypted result is the signature
</CipherData>
</EncryptedData>
</CreditCard>
</PaymentInfo>

XML Signature Verification XML Canonicalization


• Verifying digital signature (roughly): • For signature, data is digested
• Digest the data • Digest algorithms work with octet streams
• Equivalent XML may have different octet stream
• Decrypt the signature (with known public key of
representations:
signer, or with shared key) <element att="val"/>
• The digest must match the decrypted signature <element att = 'val' />
• Signature verifies data is same as was • Canonicalization (C14N) prescribes the one
serialization
signed
• Serious issues with namespaces, other inherited
• With public-key cryptography, signature also values (xml:base, xml:lang etc.)
gives non-repudiation • Must be inherited to be verified by signature
• Same applies to encrypting only parts of XML documents

3
XML Key Management,
Web Services Security
XACML, SAML
• XKMS – XML Key Management Specification • WS-Security specification
• Distributing and registering public keys • Puts all the above together in SOAP
• Minimizing complexity of using XML Signature • Runtime specifications
• WS-SecurityPolicy
• XACML – eXtensible Access Control Markup • Describes security policies of Web services
Language
• Design/deployment-time
• Authorization policies
• SAML – Security Assertion Markup Language
• Authentication, transfer of authentication and authorization
decisions

Web Services Security Web Services Security


Example Example
<S11:Envelope> <ds:Signature>
<S11:Header> <ds:SignedInfo>
<wsse:Security> <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<wsse:BinarySecurityToken wsu:Id="X509Token"> <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
MIIEZzCCA9CgAwIBAgIQEmtJZc0rqrKh5i... <ds:Reference URI="#body">
</wsse:BinarySecurityToken> <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
… <!-- signature --> <ds:DigestValue>LyLsF094hPi4wPU...
</wsse:Security> </ds:DigestValue>
</S11:Header> </ds:Reference>
<S11:Body wsu:Id="body"> </ds:SignedInfo>
<xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" wsu:Id="enc1"> <ds:SignatureValue>
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/> Hp1ZkmFZ/2kQLXDJbchm5gK...
<xenc:CipherData> </ds:SignatureValue>
<xenc:CipherValue>d2FpbmdvbGRfE0lm4byV0... <ds:KeyInfo>
</xenc:CipherValue> <wsse:SecurityTokenReference>
</xenc:CipherData> <wsse:Reference URI="#X509Token"/>
</xenc:EncryptedData> </wsse:SecurityTokenReference>
</S11:Body> </ds:KeyInfo>
</S11:Envelope> </ds:Signature>

Java Security API


Security in Java
Generating Digests
• Java Security API (since JDK 1.1) MessageDigest messagedigest =
MessageDigest.getInstance("SHA");
• java.security
• Algorithm-independent and extensible int n = 0;
• Implementation-independent byte [] bytes = new byte [1000];

while ((n = inputstream.read(bytes)) > -1)


• Generating digests {
messagedigest.update(bytes, 0, n);
• Creating and verifying signatures }

byte [] digest = messagedigest.digest();

4
Java Security API Java Security API
Creating Digital Signatures Verifying Digital Signatures
PrivateKey privatekey = PublicKey publickey =
(PrivateKey)KeyTools.readFromFile(filePrivate); (PublicKey)KeyTools.readFromFile(filePublic);
Signature signature = Signature.getInstance("DSA"); Signature signature = Signature.getInstance("DSA");
signature.initSign(privatekey); signature.initVerify(publickey);

int n = 0; int n = 0;
byte [] bytes = new byte [1000]; byte [] bytes = new byte [1000];

while ((n = inputstream.read(bytes)) > -1) while ((n = inputstream.read(bytes)) > -1)
{ {
signature.update(bytes, 0, n); signature.update(bytes, 0, n);
} }
bytes [] signdata = signature.sign(); boolean result = signature.verify(signdata);

Java Security API


Security in Java
Encryption
• Java Cryptography Extension (since JDK1.4) KeyGenerator keygen = KeyGenerator.getInstance("DES");
SecretKey desKey = keygen.generateKey();
• javax.crypto
Cipher desCipher =
Cipher.getInstance("DES/ECB/PKCS5Padding");
• Encryption, decryption
// Initialize the cipher for encryption
desCipher.init(Cipher.ENCRYPT_MODE, desKey);

byte[] cleartext = "This is just an example".getBytes();

// Encrypt the cleartext


byte[] ciphertext = desCipher.doFinal(cleartext);

Java Security API


Security in MIDP
Decryption
// KeyGenerator keygen = KeyGenerator.getInstance("DES"); • MIDP 2.0
// SecretKey desKey = keygen.generateKey();
• Mandates HTTPS
Cipher desCipher = • Optionally supports Java Security API
Cipher.getInstance("DES/ECB/PKCS5Padding"); • Does not support Java Cryptography Extension
// Initialize the cipher for decryption, symmetrical key • Bouncy Castle
desCipher.init(Cipher.DECRYPT_MODE, desKey); • Lightweight Cryptography API
• Implementation that works in MIDP/J2ME
// byte[] ciphertext = /* the ciphertext from previous code */;
• Not optimized, especially for public-key algorithms
// Decrypt the ciphertext • http://bouncycastle.org/
byte[] cleartext1 = desCipher.doFinal(ciphertext);

5
Summary
• Security is a complex topic
• Nothing is totally secure – price trade-off
• Social engineering, brute force, physical force
• Web security solves authentication and
confidentiality
• XML security adds non-repudiation, authorization,
identity federation
• XML security also applies to Web services

• Java provides easy-to-use Security API


• For mobile devices, there are lightweight alternatives

Das könnte Ihnen auch gefallen