5

I've set up S/MIME on my iPhone, but unlike other mail clients, I'm not given the option to select the hash or encryption algorithms. I assume iOS makes this decision for me.

Can anyone tell me what algorithms are used and what the key sizes are? It would be nice to know that the NSA are going to have a hard time to break into my Facebook notifications. :D

4
  • 1
    If Facebook gives the NSA access to all the information server-side, the encryption of the notifications becomes far less urgent, no? :-/
    – Daniel
    Aug 29, 2013 at 13:25
  • Since you have two answers addressing the certificate generation itself and how iOS mail client uses that key (and we're unlikely to get the code Apple uses internally, perhaps you could expand on the "what next" or what you are going to use this information to change what you have done. Basically, what's the practical application of the answer you expect? (so that it might guide someone to provide an answer that you might accept.)
    – bmike
    Aug 30, 2013 at 20:01
  • I wonder how setting S/MIME on your iPhone would make Facebook send its notifications encrypted? Am I missing something?
    – not2savvy
    Jan 17, 2018 at 11:23
  • @not2savvy It won't make them send it encrypted. There's usually an attachment in the form of *.p7s if you receive an encrypted message where your client is not configured properly to decrypt it.
    – cottsak
    Jan 19, 2018 at 0:49

2 Answers 2

5

SHA-1 is most likely it. Here's what I've found to support that claim:

On the Cryptographic Message Syntax Services Reference document, it is stated that the S/MIME version used is 3.1, which is defined here and where it's stated that it supports SHA-1, SHA-256, SHA-384, and SHA-512 but:

The SHA-256, SHA-384, and SHA-512 algorithms [FIPS180-2] are not currently recommended in S/MIME, and are included here for completeness.

Even more, on the Certificate, Key, and Trust Services Reference document (although it's the Mac version), it's stated that the default algorithm used is the SHA-1.

In another document, it is said:

The most common hash function you will use is SHA-1, an algorithm developed and published by the U.S. Government that produces a 160-bit hash value from any data up to 2**64 bits in length. There are also a number of more exotic algorithms such as SHA-2, elliptic-curve-based algorithms, and so on.

For compatibility with existing systems and infrastructure, you may occasionally need to use older algorithms such as MD5, but they are not recommended for use in new designs because of known weaknesses.

So, although I couldn't find any direct statement confirming the use of the SHA-1 algorithm, clues point in that direction.

2
  • Thanks for that research. It's fairly helpful. Did you have any insight into the encryption algorithms - this is what I'm more interested in TBH.
    – cottsak
    Aug 21, 2013 at 0:43
  • @cottsak All that I could find is this, written in the first document I've linked to: On CMS terminology, this module performs encryption using the **enveloped-data content** type and signing using the signed-data content type. If the message is both signed and encrypted, it uses **nested ContentInfo** types.
    – Thecafremo
    Aug 21, 2013 at 9:56
3

For a specific message, you can use openssl asn1parse to peek inside.

I sent myself a message using iOS Mail, signed and encrypted to me, and using the command line

$ openssl smime -pk7out -in message.eml | openssl asn1parse

and the contents of the results showed the message appears to be encrypted with 3DES EDE in CBC mode:

  913:d=5  hl=2 l=   8 prim: OBJECT            :des-ede3-cbc

Finding the signature algorithm is another challenge. I think it's SHA-1, but the decrypted message includes a lot of certificate signatures, and I'm not sure which is the message's.

$ openssl smime -decrypt -in smime.eml -recip me.crt -inkey me.key | \
    openssl smime -pk7out | openssl asn1parse

   30:d=5  hl=2 l=   5 prim: OBJECT            :sha1

While the question is actually asking about the symmetric and hash algorithm used to encrypt the message data, the parameters for the certificate itself (which contains the public key used to encrypt the symmetric key which is, in turn used to deal with the data) are selected at key generation time. I've seen this in action while generating a new personal key pair at StartSSL; the web interface asks for the size of the RSA key and which signature algorithm I wish to use, along with the warning that choosing SHA-1 will leave you with a certificate incompatible with some systems.

For what it's worth, my own personal certificate uses 2048-bit RSA and the SHA-1 signature algorithm, which I've found works well across several different systems, including OS X Mail.app, iOS Mail, and Outlook 2007.

7
  • That actually doesn't help my question. I'm actually looking for evidence of the internal implementation on iOS devices like iPhones and iPads. Thanks tho
    – cottsak
    Aug 30, 2013 at 1:49
  • The key size is determined by CA, but the encryption algorithm is determined by email client. forums.comodo.com/email-certificate/… Aug 30, 2013 at 18:50
  • I see. @cottsak is talking about the symmetric/hash algorithms used for the data, not the public-key/hash algorithms used for the key (c.f. en.wikipedia.org/wiki/Hybrid_cryptosystem). Looks like I took a stab in the dark by not asking that question, and hit the wrong target. Let me make a few clarifying edits as I think this is still valuable information, if tangential.
    – zigg
    Aug 30, 2013 at 19:49
  • 1
    I did a bit more looking and ended up deconstructing a message I sent. Have a look at the latest edits.
    – zigg
    Aug 30, 2013 at 20:27
  • That's very interesting.. so are you suggesting that iOS chooses the hash and message encryption algorithm depending on what the signing certificate specifies?
    – cottsak
    Sep 2, 2013 at 9:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .