
snej@2: h1=. MYCrypto
snej@2: 
snej@9: p=. Version 0.2 -- 12 April 2009
snej@2: 
snej@2: p=. By "Jens Alfke":mailto:jens@mooseyard.com <br>
snej@2: Based in part on code by Wade Tregaskis, <br>
snej@2: and sample code by Apple Computer.
snej@2: 
snej@2: h2. Introduction
snej@2: 
snej@2: *MYCrypto* is a high-level cryptography API for Mac OS X and iPhone. It's an Objective-C wrapper around the system
snej@2: "*Keychain*":http://developer.apple.com/documentation/Security/Conceptual/keychainServConcepts/02concepts/concepts.html#//apple_ref/doc/uid/TP30000897-CH204-TP9
snej@2: and *CSSM* APIs, which are notoriously hard to use, as well as *CommonCrypto*, which is easier but quite limited.
snej@2: 
snej@4: MYCrypto gives you easy object-oriented interfaces to:
snej@2: 
snej@2: * Symmmetric cryptography (session keys and password-based encryption)
snej@2: * Asymmetric cryptography (public and private keys; digital signatures)
snej@5: * Identity certificates (for use with SSL and CMS)
snej@2: * Cryptographic digests/hashes (effectively-unique IDs for data)
snej@2: * The Keychain (a secure, encrypted storage system for keys and passwords)
snej@9: * Cryptographic Message Syntax [CMS] for signing/encrypting data
snej@2: 
snej@8: It's open source, released under a friendly BSD license.
snej@8: 
snej@2: h3. Requirements
snej@2: 
snej@2: * Mac OS X 10.5 or later _[has been tested on 10.5.6]_
snej@6: * or iPhone OS 2.0 or later _[not yet tested; see Limitations section below]_
snej@6: * or iPhone Simulator, for iPhone OS 2.0 or later
snej@3: * The "MYUtilities":http://mooseyard.com/hg/hgwebdir.cgi/MYUtilities library, which is used by MYCrypto.
snej@2: * _Some understanding of security and cryptography on your part!_ Even with convenient APIs, cryptographic operations still require care and knowledge to be used safely. There are already too many "examples":http://en.wikipedia.org/wiki/Wired_Equivalent_Privacy#Flaws of insecure systems that were incorrectly assembled from secure primitives; don't add your app to that list. Please read a good overview like "??Practical Cryptography??":http://www.schneier.com/book-practical.html before attempting anything the least bit fancy.
snej@2: 
snej@6: h3. How To Get It
snej@2: 
snej@6: * "Download the current source code":http://mooseyard.com/hg/hgwebdir.cgi/MYCrypto/archive/tip.zip
snej@6: * To check out the source code using "Mercurial":http://selenic.com/mercurial/:<br>
snej@8: @hg clone http://mooseyard.com/hg/hgwebdir.cgi/MYCrypto/ MYCrypto@
snej@6: * As described above, you'll also need to download or check out MYUtilities and put it in a directory next to MYCrypto.
snej@6: * Or if you're just looking:
snej@6: ** "Browse the source code":http://mooseyard.com/hg/hgwebdir.cgi/MYCrypto/file/tip
snej@6: ** "Browse the class documentation":Documentation/html/hierarchy.html
snej@2: 
snej@2: h2. Overview
snej@2: 
snej@2: The class hierarchy of MYCrypto looks like this:
snej@2: 
snej@5: * "_MYKeychain_":Documentation/html/interfaceMYKeychain.html
snej@5: * "_MYKeychainItem_":Documentation/html/interfaceMYKeychainItem.html
snej@5: ** "_MYKey_":Documentation/html/interfaceMYKey.html
snej@5: *** "MYSymmetricKey":Documentation/html/interfaceMYSymmetricKey.html
snej@5: *** "MYPublicKey":Documentation/html/interfaceMYPublicKey.html
snej@5: *** "MYPrivateKey":Documentation/html/interfaceMYPrivateKey.html
snej@5: *** "MYCertificate":Documentation/html/interfaceMYCertificate.html
snej@5: **** "MYIdentity":Documentation/html/interfaceMYIdentity.html
snej@5: * "_MYDigest_":Documentation/html/interfaceMYDigest.html
snej@5: ** "MYSHA1Digest":Documentation/html/interfaceMYSHA1Digest.html
snej@5: ** "MYSHA256Digest":Documentation/html/interfaceMYSHA256Digest.html
snej@2: * "MYCryptor":Documentation/html/interfaceMYCryptor.html
snej@9: * "MYEncoder":Documentation/html/interfaceMYEncoder.html
snej@9: * "MYDecoder":Documentation/html/interfaceMYDecoder.html
snej@9: * "MYSigner":Documentation/html/interfaceMYSigner.html
snej@2: 
snej@5: (_Italicized_ classes are abstract.)
snej@2: 
snej@6: h2. Current Limitations
snej@6: 
snej@6: h3. First off, the biggest caveat of all:
snej@6: 
snej@9: * *MYCrypto 0.2 is new code and has not yet been used in any real projects. Expect bugs.* (I'm talking about my wrapper/glue code. The underlying cryptographic functionality provided by the OS is robust.)
snej@6: 
snej@9: h3. Further issues with the 0.2 release:
snej@6: 
snej@6: * *MYCrypto does not yet work on the iPhone.* It currently builds, but runs into problems at runtime. I'm currently trying to figure these out. (The iPhone OS Security APIs are very different from the Mac OS X ones, and I'm much less familiar with them.) However, it does work in the iPhone Simulator, which uses the OS X APIs.
snej@6: * Exporting symmetric keys in wrapped (encrypted) form will fail. Currently they can be exported only as raw key data.
snej@6: * Importing symmetric keys, in any form, will fail ... kind of a deal-breaker for using them across two computers, unfortunately.
snej@6: 
snej@6: h3. Current API limitations, to be remedied in the future:
snej@6: 
snej@6: * No API for accessing passwords; fortunately there are several other utility libraries that provide this. And if your code is doing cryptographic operations, it probably needs to store the keys themselves, not passwords.
snej@6: * No evaluation of trust in certificates (i.e. SecTrust and related APIs.)
snej@6: * Error reporting is too limited. Most methods indicate an error by returning nil, NULL or NO, but don't provide the standard "out" NSError parameter to provide more information. Expect the API to be refactored in the near future to remedy this.
snej@6: 
snej@2: h2. References
snej@2: 
snej@2: * "??Security Overview??":http://developer.apple.com/documentation/Security/Conceptual/Security_Overview/Introduction/Introduction.html (Apple)
snej@2: * "??Secure Coding Guide??":http://developer.apple.com/documentation/Security/Conceptual/SecureCodingGuide/Introduction.html (Apple)
snej@2: 
snej@2: * "??Common Security: CDSA and CSSM, Version 2??":http://www.opengroup.org/publications/catalog/c914.htm (The Open Group)
snej@2: 
snej@2: * "??Practical Cryptography??":http://www.schneier.com/book-practical.html (Ferguson and Schneier)
snej@5: * "??Handbook of Applied Cryptography??":http://www.cacr.math.uwaterloo.ca/hac/ (Menezes, van Oorschot, Vanstone) -- free download!
snej@2: * "??The Devil's InfoSec Dictionary??":http://www.csoonline.com/article/220527/The_Devil_s_Infosec_Dictionary (CSO Online)



