MYASN1Object.h
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--
* More work on iPhone compatibility.
* Restored the signature-verification code to MYCertInfo, which I'd removed earlier. I now need it to verify self-signed certs, since the Security framework won't do it for me.
* Merged MYCertificate-iPhone.m into MYCertificate.m since there's more shared code now.
     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 - (id) initWithSignedData: (NSData*)signedData;
    49 - (id) initWithUnsignedData: (NSData*) unsignedData;
    50 @property (readonly) NSData *signedData, *unsignedData;
    51 @end
    52 
    53 
    54 /* An ordered string of bits, as used in ASN.1.
    55     This differs from NSData in that it need not occupy a whole number of bytes;
    56     that is, the number of bits need not be a multiple of 8.
    57     This is mostly used internally by MYParsedCertificate. */
    58 @interface MYBitString : NSObject 
    59 {
    60     @private
    61     NSData *_bits;
    62     NSUInteger _bitCount;
    63 }
    64 
    65 - (id)initWithBits: (NSData*)bits count: (NSUInteger)bitCount;
    66 + (MYBitString*) bitStringWithData: (NSData*)bits;
    67 
    68 @property (readonly, nonatomic) NSData *bits;
    69 @property (readonly, nonatomic) NSUInteger bitCount;
    70 
    71 @end