See the reasons David listed why we use OpenSSL, especially compatibility and size.
The absence of those (which NSS implies) are clear cons.
First, here's my recollection of why Android uses OpenSSL instead of NSS (I didn't make this decision, I joined the project later):
- code size: OpenSSL is much smaller than NSS
- speed: OpenSSL provides optimized assembly routines for ARM, and NSS does not.
- maintenance: We use the OpenSSL version maintained by the Android team ($ANDROID/external/openssl), though we have a few of our own patches on top of it, i.e. we share maintenance work with them.
- compatibility: To work around platform bugs that existed before Android 4.2, we sometime have to get an OpenSSL keypair handle (EVP_PKEY) from the system, and use it with our own copy of OpenSSL to perform signing / verification (this works because these object layouts are stable between OpenSSL releases, but there is no guarantee that this will always be the case).
- This is not an initial reason, but is important if we consider switching to something else.
IMHO, if considering moving all platforms to move to OpenSSL:Pros
- Reduced code size
- Reduced maintenance work (alleged, see note below).
Cons
- OpenSSL doesn't natively use platform Keychain APIs to perform certificate lookup/validation/installation, this must be performed through client-provided callbacks. We wrote them for Android, but new versions would be needed for Win, OS X, etc... There may be some API mismatches making this non-trivial though. In all cases, that's still a lot of new code which will have to be carefully tested (and most of these system APIs _cannot_ be unit-tested, as far as I understand, ain't that fun?).
- On Linux, I believe we currently use the NSS-provided certificate store, because there are multiple incompatible keychain APIs (gnome-keyring and kwallet being the main ones), though there is an effort to provide a standardized API at http://www.freedesktop.org/wiki/Specifications/secret-storage-spec/. I believe OpenSSL allows you to implement your own store as well, but I'm unsure its API has all the features we'd need (especially with regards to client certificate storage / filtering). Hopefully some experts could chime in.
- OpenSSL APIs are really really horrible, from a comprehension and maintenance point of view. The library is no doubt written by talented cryptographers, but the API isn't (for historical reasons that would be hard to fix without breaking lots of existing client sources). I have worked extensively with it in the past year, and I'm convinced it's still impossible to use this library properly without multiple passes over its source code to really understand what's going on. While some of that comes from the subject's complexity (crypto _is_ hard), the majority of the issues are non-existing-documentation-at-all, existing-but-badly-written-documentation, and legacy implementation details that are exposed by the public API and make usage painful / ambiguous / perplexing. It's completely possible to write client code for it (we did), but there is a huge mental effort involved that doesn't seem to be required when looking at the NSS APIs (I had to work with them too).
This ^ is not really a con if the alternative is retaining both the NSS and OpenSSL ports. That is to say, with the status quo we already incur this specific downside in spades.OTOH, if the alternative is to move purely to NSS, this is most certainly a drawback of picking OpenSSL.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
I think one argument was that OpenSSL is smaller - this would matter even if we compile it in statically.I did some measurements on my Gentoo system:Total package size (all installed files, obtained using equery size):dev-libs/nss-3.15.2 : 17.35 MiBdev-libs/openssl-1.0.1e-r1 : 15.38 MiBJust the shared libraries (obtained using equery files <package> 2>/dev/null | grep '.so' | grep -v debug | xargs du -hsc):dev-libs/nss-3.15.2 : 3.6 MBdev-libs/openssl-1.0.1e-r1 : 2.6 MBIt's not obvious to me whether the savings are "big enough" (and whether we use all of the .so libraries - that may change the picture as well; maybe one way to measure would be to compare sizes of linux and linux redux build).Isn't it also an advantage of NSS that Wan-Teh is a developer of NSS? :)
On Wed, Dec 11, 2013 at 9:58 PM, Ryan Sleevi <rsl...@chromium.org> wrote:> realise some savings, but I don't think they'll be extreme.
> Right now, I don't think the dual-maintenance cost is a gross burden, and,
> if anything, forces API design decisions to be properly interoperable (I am,
> for example, thinking of WebCrypto in this case, which benefits from having
> two compatible underlying library implementations). Long term, we can
Speaking of WebCrypto and Windows/Mac support, has anyone thought
about using the Crytography: Next Generation [1] and Common Crypto [2]
API as performance optimisations?
I know that some of these APIs are already used in chromium but not
widely and not used for WebCrypto implementation yet, but we have at
least found some quite significant performance improvements by using
CNG and Common Crypto over NSS for digest calculation at least. We
have yet to measure how they compare with OpenSSL, but if they have a
stable API and provides equal or higher performance, would they be a
better fit for Windows and Mac?
- Jiang