MYASN1Object.h
author Jens Alfke <jens@mooseyard.com>
Fri Jun 05 08:57:18 2009 -0700 (2009-06-05)
changeset 20 df9da0f6b358
parent 16 c409dbc4f068
child 21 2c300b15b381
permissions -rw-r--r--
Factored out the name accessors of MYParsedCertificate into a new class MYCertificateName, so that both subject and issuer can be accessed. A bit of other cleanup too.
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@16
    48
@end
jens@16
    49
jens@16
    50
jens@19
    51
/* An ordered string of bits, as used in ASN.1.
jens@16
    52
    This differs from NSData in that it need not occupy a whole number of bytes;
jens@19
    53
    that is, the number of bits need not be a multiple of 8.
jens@19
    54
    This is mostly used internally by MYParsedCertificate. */
jens@16
    55
@interface MYBitString : NSObject 
jens@16
    56
{
jens@19
    57
    @private
jens@16
    58
    NSData *_bits;
jens@16
    59
    NSUInteger _bitCount;
jens@16
    60
}
jens@16
    61
jens@16
    62
- (id)initWithBits: (NSData*)bits count: (NSUInteger)bitCount;
jens@19
    63
+ (MYBitString*) bitStringWithData: (NSData*)bits;
jens@16
    64
jens@16
    65
@property (readonly, nonatomic) NSData *bits;
jens@16
    66
@property (readonly, nonatomic) NSUInteger bitCount;
jens@16
    67
jens@16
    68
@end