Skip to content
A high-level cryptography API for Mac OS X and iPhone. (Mirror of Mercurial repo at https://bitbucket.org/snej/mycrypto)
Objective-C
Find file
Failed to load latest commit information.
MYCrypto.xcodeproj Modernized array/dict/box syntax Dec 30, 2012
Tests Various fixes & improvements, including ability to check signatures u… Mar 6, 2011
iPhone * Fixed bug in MYIdentityEnumerator: if it hit an identity whose cert… Feb 18, 2010
.hgignore * MYDigest.algorithm returns CCHmacAlgorithm type now on iOS. Apr 16, 2011
.hgtags Added tag v0.5 for changeset 38b63726395d Apr 17, 2011
MYASN1Object.h ARC conversion Dec 30, 2012
MYASN1Object.m ARC conversion Dec 30, 2012
MYBERParser.h Various fixes & improvements, including ability to check signatures u… Mar 7, 2011
MYBERParser.m Modernized array/dict/box syntax Dec 30, 2012
MYCertificate.h ARC conversion Dec 30, 2012
MYCertificate.m Fixed a few leaks Aug 3, 2013
MYCertificateInfo.h ARC conversion Dec 30, 2012
MYCertificateInfo.m Modernized array/dict/box syntax Dec 30, 2012
MYCertificateTest.m Modernized array/dict/box syntax Dec 30, 2012
MYCrypto+Cocoa.h * Added MYEncoder/Decoder (CMS) Apr 12, 2009
MYCrypto+Cocoa.m * Some cleanup. Got the test cases to pass again. Apr 19, 2009
MYCrypto.h * Added ASN.1 / BER / DER utilities, to be used in generating and par… Jun 2, 2009
MYCrypto.xcconfig Fixed a few leaks and unnecessary variables reported by the static an… Feb 17, 2010
MYCryptoConfig.h ARC conversion Dec 30, 2012
MYCryptoTest.m ARC conversion Dec 30, 2012
MYCrypto_Debug.xcconfig Fixed a few leaks and unnecessary variables reported by the static an… Feb 17, 2010
MYCrypto_Prefix.pch Cleanup: fix header comments, remove obsolete files. Apr 21, 2011
MYCrypto_Private.h ARC conversion Dec 30, 2012
MYCrypto_Release.xcconfig Fixed a few leaks and unnecessary variables reported by the static an… Feb 17, 2010
MYCrypto_main.m Cleanup: fix header comments, remove obsolete files. Apr 21, 2011
MYCryptor.h ARC conversion Dec 30, 2012
MYCryptor.m Fixed a few minor issues noticed by new version of Clang Aug 3, 2013
MYDEREncoder.h ARC conversion Dec 30, 2012
MYDEREncoder.m Modernized array/dict/box syntax Dec 30, 2012
MYDecoder.h Cleanup: fix header comments, remove obsolete files. Apr 21, 2011
MYDecoder.m Modernized array/dict/box syntax Dec 30, 2012
MYDigest.h ARC conversion Dec 30, 2012
MYDigest.m ARC conversion Dec 30, 2012
MYEncoder.h * Added MYEncoder/Decoder (CMS) Apr 13, 2009
MYEncoder.m ARC conversion Dec 30, 2012
MYIdentity.h ARC conversion Dec 30, 2012
MYIdentity.m Fixed a few leaks Aug 4, 2013
MYKey-iPhone.m Modernized array/dict/box syntax Dec 30, 2012
MYKey.h ARC conversion Dec 30, 2012
MYKey.m ARC conversion Dec 30, 2012
MYKeychain-iPhone.m Modernized array/dict/box syntax Dec 30, 2012
MYKeychain.h ARC conversion Dec 30, 2012
MYKeychain.m Fixed a few leaks Aug 4, 2013
MYKeychainItem.h ARC conversion Dec 30, 2012
MYKeychainItem.m Modernized array/dict/box syntax Dec 30, 2012
MYMockKeys.h Updated API docs. Apr 17, 2011
MYMockKeys.m ARC conversion Dec 30, 2012
MYOID.h Various fixes & improvements, including ability to check signatures u… Mar 7, 2011
MYOID.m ARC conversion Dec 30, 2012
MYPrivateKey.h ARC conversion Dec 30, 2012
MYPrivateKey.m Modernized array/dict/box syntax Dec 30, 2012
MYPublicKey.h ARC conversion Dec 30, 2012
MYPublicKey.m Modernized array/dict/box syntax Dec 30, 2012
MYSymmetricKey-iPhone.m Modernized array/dict/box syntax Dec 30, 2012
MYSymmetricKey.h Added MYMockKeys (unit testing helper). Fixed a Clang compile error. … Nov 30, 2010
MYSymmetricKey.m Fixed a few minor issues noticed by new version of Clang Aug 4, 2013
README.md Added README.md (for GitHub) May 12, 2012
X509Guide.txt Various fixes & improvements, including ability to check signatures u… Mar 7, 2011
maindocs.h Updated API docs. Apr 17, 2011

README.md

MYCrypto

Version 0.51 — 12 May 2012

By Jens Alfke

Introduction

MYCrypto is a high-level cryptography API for Mac OS X and iPhone. It's an Objective-C wrapper around the system Keychain and CSSM APIs, which are notoriously hard to use, as well as CommonCrypto, which is easier but quite limited.

MYCrypto gives you easy object-oriented interfaces to:

  • Symmmetric cryptography (session keys and password-based encryption)
  • Asymmetric cryptography (public and private keys; digital signatures)
  • Creating and managing X.509 certificates (for use with SSL, S/MIME and CMS)
  • Cryptographic digests/hashes (effectively-unique IDs for data)
  • The Keychain (a secure, encrypted storage system for keys and passwords)
  • Cryptographic Message Syntax [CMS] for signing/encrypting data
  • Parsing and generating ASN.1, BER and DER (the weird binary data formats used by crypto standards)

It's open source, released under a friendly BSD license.

Setup

Kindly direct your eyes to the Setup page...

Overview

The class hierarchy of MYCrypto looks like this:

  • MYKeychain
  • MYKeychainItem
    • MYKey
      • MYSymmetricKey
      • MYPublicKey
      • MYPrivateKey
      • MYCertificate
      • MYIdentity
  • MYDigest
    • MYSHA1Digest
    • MYSHA256Digest
  • MYCryptor
  • MYEncoder
  • MYDecoder
  • MYSigner
  • MYCertificateInfo
    • MYCertificateRequest

(Italicized classes are abstract.)

Examples

Please see the Examples page.

Current Limitations

  • Certificate generation only supports self-signed certs, not cert requests sent to an external signer.
  • Some functionality doesn't work on iPhone. The security APIs in iOS are new and rather poorly documented and poorly understood by me. Specifically, anything involving keys not stored in a keychain is unlikely to work. This is mostly an issue with symmetric session keys.

Current API limitations, to be remedied in the future:

  • No API for accessing Keychain 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.
  • 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 eventually to remedy this.
  • Some functionality is not available on iOS, generally because there is no underlying API for it on that platform, or because the API is different from the Mac OS API and I haven't written wrapper code for it yet.

References

Something went wrong with that request. Please try again.