author | Jens Alfke <jens@mooseyard.com> |
Tue Jun 09 23:58:03 2009 -0700 (2009-06-09) | |
changeset 24 | 6856e071d25a |
parent 19 | f6c91b9da05b |
permissions | -rw-r--r-- |
jens@16 | 1 |
// |
jens@16 | 2 |
// MYASN1Object.h |
jens@16 | 3 |
// MYCrypto-iPhone |
jens@16 | 4 |
// |
jens@16 | 5 |
// Created by Jens Alfke on 5/28/09. |
jens@16 | 6 |
// Copyright 2009 Jens Alfke. All rights reserved. |
jens@16 | 7 |
// |
jens@16 | 8 |
|
jens@16 | 9 |
#import <Foundation/Foundation.h> |
jens@16 | 10 |
|
jens@16 | 11 |
|
jens@19 | 12 |
/* A generic ASN.1 data value. The BER parser instantiates these to represent parsed values that |
jens@19 | 13 |
it doesn't know how to represent otherwise. |
jens@19 | 14 |
This is mostly used internally by MYParsedCertificate. */ |
jens@16 | 15 |
@interface MYASN1Object : NSObject |
jens@16 | 16 |
{ |
jens@16 | 17 |
@private |
jens@16 | 18 |
uint32_t _tag; |
jens@16 | 19 |
uint8_t _tagClass; |
jens@16 | 20 |
BOOL _constructed; |
jens@16 | 21 |
NSData *_value; |
jens@16 | 22 |
NSArray *_components; |
jens@16 | 23 |
} |
jens@16 | 24 |
|
jens@16 | 25 |
- (id) initWithTag: (uint32_t)tag |
jens@16 | 26 |
ofClass: (uint8_t)tagClass |
jens@16 | 27 |
constructed: (BOOL)constructed |
jens@16 | 28 |
value: (NSData*)value; |
jens@16 | 29 |
- (id) initWithTag: (uint32_t)tag |
jens@16 | 30 |
ofClass: (uint8_t)tagClass |
jens@16 | 31 |
components: (NSArray*)components; |
jens@16 | 32 |
|
jens@16 | 33 |
@property (readonly) uint32_t tag; |
jens@16 | 34 |
@property (readonly) uint8_t tagClass; |
jens@16 | 35 |
@property (readonly) BOOL constructed; |
jens@16 | 36 |
@property (readonly) NSData *value; |
jens@16 | 37 |
@property (readonly) NSArray *components; |
jens@16 | 38 |
|
jens@16 | 39 |
+ (NSString*) dump: (id)object; |
jens@16 | 40 |
|
jens@16 | 41 |
@end |
jens@16 | 42 |
|
jens@16 | 43 |
|
jens@19 | 44 |
/* An ASN.1 "big" (arbitrary-length) integer. |
jens@19 | 45 |
The value contains the bytes of the integer, in big-endian order. |
jens@19 | 46 |
This is mostly used internally by MYParsedCertificate. */ |
jens@16 | 47 |
@interface MYASN1BigInteger : MYASN1Object |
jens@21 | 48 |
- (id) initWithSignedData: (NSData*)signedData; |
jens@21 | 49 |
- (id) initWithUnsignedData: (NSData*) unsignedData; |
jens@21 | 50 |
@property (readonly) NSData *signedData, *unsignedData; |
jens@16 | 51 |
@end |
jens@16 | 52 |
|
jens@16 | 53 |
|
jens@19 | 54 |
/* An ordered string of bits, as used in ASN.1. |
jens@16 | 55 |
This differs from NSData in that it need not occupy a whole number of bytes; |
jens@19 | 56 |
that is, the number of bits need not be a multiple of 8. |
jens@19 | 57 |
This is mostly used internally by MYParsedCertificate. */ |
jens@16 | 58 |
@interface MYBitString : NSObject |
jens@16 | 59 |
{ |
jens@19 | 60 |
@private |
jens@16 | 61 |
NSData *_bits; |
jens@16 | 62 |
NSUInteger _bitCount; |
jens@16 | 63 |
} |
jens@16 | 64 |
|
jens@16 | 65 |
- (id)initWithBits: (NSData*)bits count: (NSUInteger)bitCount; |
jens@19 | 66 |
+ (MYBitString*) bitStringWithData: (NSData*)bits; |
jens@16 | 67 |
|
jens@16 | 68 |
@property (readonly, nonatomic) NSData *bits; |
jens@16 | 69 |
@property (readonly, nonatomic) NSUInteger bitCount; |
jens@16 | 70 |
|
jens@16 | 71 |
@end |