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