diff -r 000000000000 -r a06e44b9b898 MYASN1Object.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MYASN1Object.h Wed Jun 03 17:22:42 2009 -0700 @@ -0,0 +1,63 @@ +// +// MYASN1Object.h +// MYCrypto-iPhone +// +// Created by Jens Alfke on 5/28/09. +// Copyright 2009 Jens Alfke. All rights reserved. +// + +#import + + +/** A generic ASN.1 data value. The BER parser instantiates these to represent parsed values that + it doesn't know how to represent otherwise. */ +@interface MYASN1Object : NSObject +{ + @private + uint32_t _tag; + uint8_t _tagClass; + BOOL _constructed; + NSData *_value; + NSArray *_components; +} + +- (id) initWithTag: (uint32_t)tag + ofClass: (uint8_t)tagClass + constructed: (BOOL)constructed + value: (NSData*)value; +- (id) initWithTag: (uint32_t)tag + ofClass: (uint8_t)tagClass + components: (NSArray*)components; + +@property (readonly) uint32_t tag; +@property (readonly) uint8_t tagClass; +@property (readonly) BOOL constructed; +@property (readonly) NSData *value; +@property (readonly) NSArray *components; + ++ (NSString*) dump: (id)object; + +@end + + +/** An ASN.1 "big" (arbitrary-length) integer. + The value contains the bytes of the integer, in big-endian order. */ +@interface MYASN1BigInteger : MYASN1Object +@end + + +/** An ordered string of bits, as used in ASN.1. + This differs from NSData in that it need not occupy a whole number of bytes; + that is, the number of bits need not be a multiple of 8. */ +@interface MYBitString : NSObject +{ + NSData *_bits; + NSUInteger _bitCount; +} + +- (id)initWithBits: (NSData*)bits count: (NSUInteger)bitCount; + +@property (readonly, nonatomic) NSData *bits; +@property (readonly, nonatomic) NSUInteger bitCount; + +@end