jens@16: // jens@16: // MYASN1Object.h jens@16: // MYCrypto-iPhone jens@16: // jens@16: // Created by Jens Alfke on 5/28/09. jens@16: // Copyright 2009 Jens Alfke. All rights reserved. jens@16: // jens@16: jens@16: #import jens@16: jens@16: jens@19: /* A generic ASN.1 data value. The BER parser instantiates these to represent parsed values that jens@19: it doesn't know how to represent otherwise. jens@19: This is mostly used internally by MYParsedCertificate. */ jens@16: @interface MYASN1Object : NSObject jens@16: { jens@16: @private jens@16: uint32_t _tag; jens@16: uint8_t _tagClass; jens@16: BOOL _constructed; jens@16: NSData *_value; jens@16: NSArray *_components; jens@16: } jens@16: jens@16: - (id) initWithTag: (uint32_t)tag jens@16: ofClass: (uint8_t)tagClass jens@16: constructed: (BOOL)constructed jens@16: value: (NSData*)value; jens@16: - (id) initWithTag: (uint32_t)tag jens@16: ofClass: (uint8_t)tagClass jens@16: components: (NSArray*)components; jens@16: jens@16: @property (readonly) uint32_t tag; jens@16: @property (readonly) uint8_t tagClass; jens@16: @property (readonly) BOOL constructed; jens@16: @property (readonly) NSData *value; jens@16: @property (readonly) NSArray *components; jens@16: jens@16: + (NSString*) dump: (id)object; jens@16: jens@16: @end jens@16: jens@16: jens@19: /* An ASN.1 "big" (arbitrary-length) integer. jens@19: The value contains the bytes of the integer, in big-endian order. jens@19: This is mostly used internally by MYParsedCertificate. */ jens@16: @interface MYASN1BigInteger : MYASN1Object jens@21: - (id) initWithSignedData: (NSData*)signedData; jens@21: - (id) initWithUnsignedData: (NSData*) unsignedData; jens@21: @property (readonly) NSData *signedData, *unsignedData; jens@16: @end jens@16: jens@16: jens@19: /* An ordered string of bits, as used in ASN.1. jens@16: This differs from NSData in that it need not occupy a whole number of bytes; jens@19: that is, the number of bits need not be a multiple of 8. jens@19: This is mostly used internally by MYParsedCertificate. */ jens@16: @interface MYBitString : NSObject jens@16: { jens@19: @private jens@16: NSData *_bits; jens@16: NSUInteger _bitCount; jens@16: } jens@16: jens@16: - (id)initWithBits: (NSData*)bits count: (NSUInteger)bitCount; jens@19: + (MYBitString*) bitStringWithData: (NSData*)bits; jens@16: jens@16: @property (readonly, nonatomic) NSData *bits; jens@16: @property (readonly, nonatomic) NSUInteger bitCount; jens@16: jens@16: @end