e3ae9d1aa18f7b82be9791b782d8c570d1dc276f
[WebKit-https.git] / WebKit / WebCoreSupport.subproj / WebNewKeyGeneration.h
1 /*
2  *  WebNewKeyGeneration.h
3  *  WebKit
4  *
5  *  Created by Chris Blumenberg on Mon Aug 23 2004.
6  *  Copyright (c) 2003 Apple Computer. All rights reserved.
7  *
8  */
9
10 #ifndef WEB_KEY_GENERATION_H
11 #define WEB_KEY_GENERATION_H
12
13 #import <WebKit/WebKeyGenerator.h>
14
15 #ifdef USE_NEW_KEY_GENERATION
16
17 #import <CoreFoundation/CoreFoundation.h>
18
19 #import <Security/asn1Templates.h>
20 #import <Security/SecAsn1Coder.h>
21 #import <Security/secasn1t.h>
22 #import <Security/Security.h>
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27     
28     /* 
29     * Netscape Certifiate Sequence is defined by Netscape as a PKCS7
30      * ContentInfo with a contentType of netscape-cert-sequence and a content
31      * consisting of a sequence of certificates.
32      *
33      * For simplicity - i.e., to avoid the general purpose ContentInfo
34      * polymorphism - we'll just hard-code this particular type right here.
35      *
36      * Inside the ContentInfo is an array of standard X509 certificates.
37      * We don't need to parse the certs themselves so they remain as 
38      * opaque data blobs. 
39      */
40     typedef struct {
41         CSSM_OID                contentType;            // netscape-cert-sequence
42         CSSM_DATA               **certs;
43     } NetscapeCertSequence;
44     
45     extern const SecAsn1Template NetscapeCertSequenceTemplate[];
46     
47     /*
48      * Public key/challenge, to send to CA.
49      *
50      * PublicKeyAndChallenge ::= SEQUENCE {
51          *
52          * ¬†        spki SubjectPublicKeyInfo,
53          *      challenge IA5STRING
54          * }
55      *
56      * SignedPublicKeyAndChallenge ::= SEQUENCE {
57          *              publicKeyAndChallenge PublicKeyAndChallenge,
58          *              signatureAlgorithm AlgorithmIdentifier,
59          *              signature BIT STRING
60          * }
61      */
62     typedef struct {
63         CSSM_X509_SUBJECT_PUBLIC_KEY_INFO       spki;
64         CSSM_DATA                                                       challenge;      // ASCII
65     } PublicKeyAndChallenge;
66     
67     typedef struct {
68         PublicKeyAndChallenge                           pubKeyAndChallenge;
69         CSSM_X509_ALGORITHM_IDENTIFIER          algId;
70         CSSM_DATA                                                       signature; // length in BITS
71     } SignedPublicKeyAndChallenge;
72     
73     extern const SecAsn1Template PublicKeyAndChallengeTemplate[];
74     extern const SecAsn1Template SignedPublicKeyAndChallengeTemplate[];
75
76     CFStringRef signedPublicKeyAndChallengeString(unsigned keySize, CFStringRef challenge, CFStringRef keyDescription);
77     WebCertificateParseResult addCertificatesToKeychainFromData(const void *bytes, unsigned length);
78     
79 #ifdef __cplusplus
80 }
81 #endif
82
83 #endif /* USE_NEW_KEY_GENERATION */
84
85 #endif /* WEB_KEY_GENERATION_H */