LT   EN   RU  
Monday 26 October 2020 - Independent and informative portal
Register   Login
News subscribe
Subscribe   Unsubscribe
Visits since 2002 09 12 - 66992691
Pages in 40735
  Computers > Computer technologies > Security > SSL certificates
Lankomumo reitingas Print version Print version
MIDP Application Security 2: Understanding SSL and TLS

Transport Layer Security (TLS) is a protocol that enables authentication and data encryption over insecure networks. It is implemented as a layer between TCP/IP and higher-level network protocols like HTTP, SMTP, and NNTP. The implementation of SSL in web browsers is nearly seamless for users, providing cryptographic authentication and session-based encryption at a minimal cost in ease of use.

This article describes TLS and its close cousin, Secure Sockets Layer (SSL). You'll learn how MIDP (the Mobile Information Device Profile) 1.0 and MIDP 2.0 support TLS and SSL, code some examples, and get an understanding of the security level of TLS and SSL.

Overview of TLS

The TLS protocol is an updated version of the SSLv3 protocol, originally created by Netscape. The two protocols are closely related, although not directly interoperable.

One of the strengths of TLS is that it operates directly on top of TCP/IP sockets, and they behave very much like TCP/IP sockets as far as higher-level protocols are concerned. As a result it's relatively easy to make network applications use an TLS socket instead of a plain vanilla socket. One common example is an application using HTTPS, which is the HTTP protocol running on a TLS or SSL socket.

The TLS protocol begins with a handshake, in which the client and server try to agree on a cipher suite, a group of cryptographic algorithms they will use for authentication and session encryption. Once the client and server have negotiated a cipher suite, they can authenticate each other and generate something called a premaster secret, which is used as the basis of the session key. The session key is used to encrypt and decrypt all data traffic sent between the client and the server. The tricky part is having both the client and server agree on a session key without ever sending it as plaintext over the network. The exact mechanism for this depends on the cipher suite selected.

As a dialogue, one likely TLS handshake looks like this:

Client : Hello, here is a list of cipher suites I can use.

Server : Hello, here is the cipher suite I chose from your
list. And here's an X.509v3 certificate that
contains my public RSA key.

Client : [Scrutinizes the certificate, checks to make sure
it's signed by a known certificate authority.]
Okay, thanks. Here's the premaster secret,
encrypted with your public key. The next thing I
say to you will be encrypted with the session

Client : [Encrypted] I'm done with the handshake.

Server : [Decrypts the premaster secret using private
key, then generates the session key.] The next
thing I send will be encrypted.

Server : [Encrypted] I'm done with the handshake too.

In this case, the client sends a premaster secret encrypted with the server's public key. The server is then authenticated, because only the server's private key can be used to decrypt the premaster secret. Even though the server already sent its certificate to the client, it proves it has the corresponding private key (and thus proves its identity) by correctly decrypting the premaster secret sent by the client. Starting from the same premaster secret, the client and server indpendently generate the same session key.

TLS also supports the use of the Diffie-Hellman (DH) key-exchange protocol. The exchange of messages is a little different from the RSA-based example above, but the end result is that both parties have the same premaster secret and can generate the same session key.

Variations are possible. The server can ask the client for its certificate, for example, although this rarely happens in practice. See the TLS specification for all the details.

Authentication in SSL and TLS

The server authenticates itself by sending its certificate to the client and proving that it possesses the corresponding private key. To verify the certificate, the client must possess the root certificate for the key that was used to sign the server's certificate. How does it get the root certificate? Desktop browsers face exactly the same problem.

The solution is the same as well. Like browsers, devices are shipped with root certificates for widely recognized certificate authorities. When a server presents a certificate, the device checks to see if it has the appropriate root certificate. If so, the device can verify the server certificate.

TLS in MIDP 1.0

The only network connection type mandated by the MIDP 1.0 specification is HTTP. Due to the flexible Generic Connection Framework, however, MIDP implementors are free to support additional connection types, including raw TLS sockets and HTTPS connections. Obtaining an HTTPS connection is just like obtaining an HTTP, except for the URL:

HttpConnection hc = (HttpConnection)"");

If you get a ConnectionNotFoundException for a server you know exists, then chances are good that the underlying implementation doesn't support HTTPS.

This approach is workable, but you have no programmatic way of finding out the identity of the server or which cipher suite is in use. If you have control of the server, you can configure it to use only cipher suites you consider secure enough for your application.

TLS support in MIDP 2.0

A MIDP 2.0 implementation must support HTTPS, where HTTPS means HTTP carried over any of the following protocols:

New APIs in MIDP 2.0 provide MIDlets with information about secure connections. In particular, the MIDP 2.0 specification includes a interface, an extension of the familiar HttpConnection. This new interface includes a getSecurityInfo() method that returns an instance of another new interface, SecurityInfo.

The SecurityInfo interface provides methods that return information about a secure connection:

public String getProtocolName()
public String getProtocolVersion()
public String getCipherSuite()
public Certificate getServerCertificate()

You can find out the name and version of the actual protocol being used, which will be one of TLS, SSL, or WTLS. The getCipherSuite() method returns the name of the cipher suite, which most likely will be one of the names defined in the TLS specification. For example, my connection from the MIDP 2.0 reference implementation emulator to returned the following cipher suite name:


This name indicates that RSA is used for key exchange, an RC4 stream cipher with a 128-bit session key is used for data encryption, and SHA-1 is used as a message digest function.

Finally, SecurityInfo's getServerCertificate() method returns an instance of javax.microedition.pki.Certificate, which represents a cryptographic certificate. The Certificate interface has methods you can use to find out the certificate's subject, its issuer, its type, and other information. You could, for example, retrieve the name on the server certificate as follows:

String url = "";
HttpsConnection hc = null;
hc = (HttpsConnection);
SecurityInfo info = hc.getSecurityInfo();
Certificate c = info.getServerCertificate();
String name = c.getIssuer();

Although the MIDP 2.0 APIs provide access to the cipher suite name, it probably won't be practical in code to examine this field and reject weak cipher suites when communicating with unknown servers. It's much more likely that you are writing a MIDlet that is part of a larger, end-to-end application, and therefore can control the allowable cipher suites at the server end. In the MIDlet, therefore, it makes sense to verify that the identity in the certificate and the cipher suite have the values you are expecting. This gives assurance that you are talking to the server you intended. If you are using HTTPS, the hostname you are using must match a field in the server's certificate; otherwise, the connection will fail. There is no such test for SSL socket connections; you would have to check the certificate in your code.

Breaking Session Keys

You've seen how easy it is to use HTTPS connections instead of HTTP connections. It's entirely transparent to the user and nearly transparent to the application developer. But how do you know that the security provided by HTTPS is sufficient?

Your goal is to make the cost of breaking the system greater than the value of the data you're protecting. One of the reasons TLS is such a nice protocol is that it uses a new session key for each conversation. Breaking a single session key gives an attacker access only to the information exchanged in that conversation.

TLS and its predecessor SSLv3 have been used and scrutinized since 1995. The protocol itself has not been compromised significantly and is not the focus of attacks. The security of TLS, then, rests on the cipher suite, particularly the key length used for the symmetric encryption of the application data.

Given the proven strength of the protocol, the best way to attack TLS is a brute-force or key-search attack on a session key. A brute-force attack consists of trying every conceivable decryption key until the plaintext emerges. On average, an attacker needs to try only half of the available keys. Brute force attacks are well suited to distributed systems; the more machines you have trying out keys, the faster it goes.

In the past, U.S. export laws restricted the length of encryption keys used in products shipped outside the United States to 40 bits. The result was that web browsers were distributed with SSL cipher suites limited to 40-bit keys — presumably becuase at the time the law was created (some time before 1996), the U.S. was able to break a 40-bit key in a comfortable length of time, perhaps a few hours or a couple of days. That was at least six years ago, or four generations of Moore's Law. If you're transmitting anything more valuable than the password to your treehouse, you're going to need longer keys.

The de facto standard for TLS cipher suites is 128 bits. Is that long enough for your application? I can't answer that question for you, of course. You have to do some rough calculations to figure out how much it would cost to break a 128-bit key, then determine whether that cost exceeds the value of your application's information.


MIDP developers now have access to secure network connections, making mobile commerce and banking applications feasible. TLS provides authentication and encryption as a layer between insecure network transport protocools (usually TCP/IP sockets) and higher-level protocols like HTTP, SMTP, and NNTP. The TLS protocol begins with a handshake, in which the client and server agree upon a cipher suite they will use to encrypt the remainder of the session. Although MIDP 1.0 does not require TLS support, MIDP 2.0 does require support for HTTPS, which is HTTP over TLS or a similar secure protocol. MIDP 2.0 also provides API support for HTTPS, giving MIDlets access to information about the secure connection. Be sure to use cipher suites that are sufficiently secure in comparison to the value of the application data. A 128-bit key is commonly used for online commerce.


Lankomumo reitingas

Diskusijos - Discusions

Versija spausdinimui - Print version

Random tags:    Badminton (3)    Astrology (10)    Biology (66)    Ecology (10)    Economics2 (2)    Show-business (11)    Yoga (4)    Feng Shui (14)    Scaners (10)    Hunting (3)    Tourism (46)    Astronomy (11)    Guns (11)    Formula 1 (2)    History (4)    Floriculture (10)    Intercourse (265)    Travels (2)    Eurointegration (4)    Prose (11)    The Rights of Man (14)    Archaeology (12)    Architecture (2)    Cats (14)    Fencing (2)    Paintball (10)    Education (174)    Art (10)    Sound systems (10)    Aviculture (2)    Automobiles (10)    Helping and prevention (14)    PHP (3)    Windows (7)    Vampire (6)    Mysticism (119)    Philosophy (2)    Open source (9)    Mobile communication (9)    Films (10)    Security (22)    Fantasy (10)    S.Valiulis (2)    Casino’s (10)    Viruses (10)    Law (11)    Countries (43)    Modems (2)    Health (20)    Pedagogics (10)
1. Introduction to SSL certificates
2. Internet Explorer, SSL and binary data
3. Where should I get my SSL Certificate?
4. What is SSL? And how can I use it?
5. What is SSL (the "little padlock")?
6. What is SSL?
7. RSA Security and GeoTrust Announce Strategic Partnership to Offer Digital Certificate Solutions
8. How do I generate a Certificate Signing Request (CSR) for my web server?
9. SSL toolkit flaw poses risk
1. How do I generate a Certificate Signing Request (CSR) for my web server?
2. What is SSL?
3. Where should I get my SSL Certificate?
4. RSA Security and GeoTrust Announce Strategic Partnership to Offer Digital Certificate Solutions
5. Internet Explorer, SSL and binary data
6. Introduction to SSL certificates
7. What is SSL? And how can I use it?
8. SSL toolkit flaw poses risk
9. What is SSL (the "little padlock")?