Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A high-level cryptography API for Mac OS X and iPhone. (Mirror of Mercurial repo at https://bitbucket.org/snej/mycrypto)

branch: master
Octocat-spinner-32 MYCrypto.xcodeproj Modernized array/dict/box syntax December 30, 2012
Octocat-spinner-32 Tests Various fixes & improvements, including ability to check signatures u… March 06, 2011
Octocat-spinner-32 iPhone * Fixed bug in MYIdentityEnumerator: if it hit an identity whose cert… February 18, 2010
Octocat-spinner-32 .hgignore * MYDigest.algorithm returns CCHmacAlgorithm type now on iOS. April 16, 2011
Octocat-spinner-32 .hgtags Added tag v0.5 for changeset 38b63726395d April 17, 2011
Octocat-spinner-32 MYASN1Object.h ARC conversion December 30, 2012
Octocat-spinner-32 MYASN1Object.m ARC conversion December 30, 2012
Octocat-spinner-32 MYBERParser.h Various fixes & improvements, including ability to check signatures u… March 06, 2011
Octocat-spinner-32 MYBERParser.m Modernized array/dict/box syntax December 30, 2012
Octocat-spinner-32 MYCertificate.h ARC conversion December 30, 2012
Octocat-spinner-32 MYCertificate.m Fixed a few leaks August 03, 2013
Octocat-spinner-32 MYCertificateInfo.h ARC conversion December 30, 2012
Octocat-spinner-32 MYCertificateInfo.m Modernized array/dict/box syntax December 30, 2012
Octocat-spinner-32 MYCertificateTest.m Modernized array/dict/box syntax December 30, 2012
Octocat-spinner-32 MYCrypto+Cocoa.h * Added MYEncoder/Decoder (CMS) April 12, 2009
Octocat-spinner-32 MYCrypto+Cocoa.m * Some cleanup. Got the test cases to pass again. April 19, 2009
Octocat-spinner-32 MYCrypto.h * Added ASN.1 / BER / DER utilities, to be used in generating and par… June 02, 2009
Octocat-spinner-32 MYCrypto.xcconfig Fixed a few leaks and unnecessary variables reported by the static an… February 17, 2010
Octocat-spinner-32 MYCryptoConfig.h ARC conversion December 30, 2012
Octocat-spinner-32 MYCryptoTest.m ARC conversion December 30, 2012
Octocat-spinner-32 MYCrypto_Debug.xcconfig Fixed a few leaks and unnecessary variables reported by the static an… February 17, 2010
Octocat-spinner-32 MYCrypto_Prefix.pch Cleanup: fix header comments, remove obsolete files. April 21, 2011
Octocat-spinner-32 MYCrypto_Private.h ARC conversion December 30, 2012
Octocat-spinner-32 MYCrypto_Release.xcconfig Fixed a few leaks and unnecessary variables reported by the static an… February 17, 2010
Octocat-spinner-32 MYCrypto_main.m Cleanup: fix header comments, remove obsolete files. April 21, 2011
Octocat-spinner-32 MYCryptor.h ARC conversion December 30, 2012
Octocat-spinner-32 MYCryptor.m Fixed a few minor issues noticed by new version of Clang August 03, 2013
Octocat-spinner-32 MYDEREncoder.h ARC conversion December 30, 2012
Octocat-spinner-32 MYDEREncoder.m Modernized array/dict/box syntax December 30, 2012
Octocat-spinner-32 MYDecoder.h Cleanup: fix header comments, remove obsolete files. April 21, 2011
Octocat-spinner-32 MYDecoder.m Modernized array/dict/box syntax December 30, 2012
Octocat-spinner-32 MYDigest.h ARC conversion December 30, 2012
Octocat-spinner-32 MYDigest.m ARC conversion December 30, 2012
Octocat-spinner-32 MYEncoder.h * Added MYEncoder/Decoder (CMS) April 12, 2009
Octocat-spinner-32 MYEncoder.m ARC conversion December 30, 2012
Octocat-spinner-32 MYIdentity.h ARC conversion December 30, 2012
Octocat-spinner-32 MYIdentity.m Fixed a few leaks August 03, 2013
Octocat-spinner-32 MYKey-iPhone.m Modernized array/dict/box syntax December 30, 2012
Octocat-spinner-32 MYKey.h ARC conversion December 30, 2012
Octocat-spinner-32 MYKey.m ARC conversion December 30, 2012
Octocat-spinner-32 MYKeychain-iPhone.m Modernized array/dict/box syntax December 30, 2012
Octocat-spinner-32 MYKeychain.h ARC conversion December 30, 2012
Octocat-spinner-32 MYKeychain.m Fixed a few leaks August 03, 2013
Octocat-spinner-32 MYKeychainItem.h ARC conversion December 30, 2012
Octocat-spinner-32 MYKeychainItem.m Modernized array/dict/box syntax December 30, 2012
Octocat-spinner-32 MYMockKeys.h Updated API docs. April 17, 2011
Octocat-spinner-32 MYMockKeys.m ARC conversion December 30, 2012
Octocat-spinner-32 MYOID.h Various fixes & improvements, including ability to check signatures u… March 06, 2011
Octocat-spinner-32 MYOID.m ARC conversion December 30, 2012
Octocat-spinner-32 MYPrivateKey.h ARC conversion December 30, 2012
Octocat-spinner-32 MYPrivateKey.m Modernized array/dict/box syntax December 30, 2012
Octocat-spinner-32 MYPublicKey.h ARC conversion December 30, 2012
Octocat-spinner-32 MYPublicKey.m Modernized array/dict/box syntax December 30, 2012
Octocat-spinner-32 MYSymmetricKey-iPhone.m Modernized array/dict/box syntax December 30, 2012
Octocat-spinner-32 MYSymmetricKey.h Added MYMockKeys (unit testing helper). Fixed a Clang compile error. … November 30, 2010
Octocat-spinner-32 MYSymmetricKey.m Fixed a few minor issues noticed by new version of Clang August 03, 2013
Octocat-spinner-32 README.md Added README.md (for GitHub) May 12, 2012
Octocat-spinner-32 X509Guide.txt Various fixes & improvements, including ability to check signatures u… March 06, 2011
Octocat-spinner-32 maindocs.h Updated API docs. April 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.