OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/keygen_handler.h" | 5 #include "net/base/keygen_handler.h" |
6 | 6 |
7 #include <Security/SecAsn1Coder.h> | 7 #include <Security/SecAsn1Coder.h> |
8 #include <Security/SecAsn1Templates.h> | 8 #include <Security/SecAsn1Templates.h> |
9 #include <Security/Security.h> | 9 #include <Security/Security.h> |
10 | 10 |
11 #include "base/base64.h" | 11 #include "base/base64.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/scoped_cftyperef.h" | 13 #include "base/scoped_cftyperef.h" |
14 | 14 |
15 // These are in Security.framework but not declared in a public header. | 15 // These are in Security.framework but not declared in a public header. |
16 extern const SecAsn1Template kSecAsn1AlgorithmIDTemplate[]; | 16 extern const SecAsn1Template kSecAsn1AlgorithmIDTemplate[]; |
17 extern const SecAsn1Template kSecAsn1SubjectPublicKeyInfoTemplate[]; | 17 extern const SecAsn1Template kSecAsn1SubjectPublicKeyInfoTemplate[]; |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 // Declarations of Netscape keygen cert structures for ASN.1 encoding: | 21 // Declarations of Netscape keygen cert structures for ASN.1 encoding: |
22 | 22 |
23 struct PublicKeyAndChallenge { | 23 struct PublicKeyAndChallenge { |
24 CSSM_X509_SUBJECT_PUBLIC_KEY_INFO spki; | 24 CSSM_X509_SUBJECT_PUBLIC_KEY_INFO spki; |
25 CSSM_DATA challenge_string; | 25 CSSM_DATA challenge_string; |
26 }; | 26 }; |
27 | 27 |
28 const SecAsn1Template kIA5StringTemplate[] = { | |
wtc
2010/04/19 22:43:45
Nit: add a comment to explain why we can't use
kSe
| |
29 { SEC_ASN1_IA5_STRING, 0, NULL, sizeof(CSSM_DATA) } | |
30 }; | |
31 | |
28 static const SecAsn1Template kPublicKeyAndChallengeTemplate[] = { | 32 static const SecAsn1Template kPublicKeyAndChallengeTemplate[] = { |
29 { | 33 { |
30 SEC_ASN1_SEQUENCE, | 34 SEC_ASN1_SEQUENCE, |
31 0, | 35 0, |
32 NULL, | 36 NULL, |
33 sizeof(PublicKeyAndChallenge) | 37 sizeof(PublicKeyAndChallenge) |
34 }, | 38 }, |
35 { | 39 { |
36 SEC_ASN1_INLINE, | 40 SEC_ASN1_INLINE, |
37 offsetof(PublicKeyAndChallenge, spki), | 41 offsetof(PublicKeyAndChallenge, spki), |
38 kSecAsn1SubjectPublicKeyInfoTemplate | 42 kSecAsn1SubjectPublicKeyInfoTemplate |
39 }, | 43 }, |
40 { | 44 { |
41 SEC_ASN1_INLINE, | 45 SEC_ASN1_INLINE, |
42 offsetof(PublicKeyAndChallenge, challenge_string), | 46 offsetof(PublicKeyAndChallenge, challenge_string), |
43 kSecAsn1IA5StringTemplate | 47 kIA5StringTemplate |
44 }, | 48 }, |
45 { | 49 { |
46 0 | 50 0 |
47 } | 51 } |
48 }; | 52 }; |
49 | 53 |
50 struct SignedPublicKeyAndChallenge { | 54 struct SignedPublicKeyAndChallenge { |
51 PublicKeyAndChallenge pkac; | 55 PublicKeyAndChallenge pkac; |
52 CSSM_X509_ALGORITHM_IDENTIFIER signature_algorithm; | 56 CSSM_X509_ALGORITHM_IDENTIFIER signature_algorithm; |
53 CSSM_DATA signature; | 57 CSSM_DATA signature; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 CSSM_ALGID_MD5WithRSA, | 252 CSSM_ALGID_MD5WithRSA, |
249 &cc_handle); | 253 &cc_handle); |
250 if (err) | 254 if (err) |
251 return err; | 255 return err; |
252 err = CSSM_SignData(cc_handle, &data, 1, CSSM_ALGID_NONE, signature); | 256 err = CSSM_SignData(cc_handle, &data, 1, CSSM_ALGID_NONE, signature); |
253 CSSM_DeleteContext(cc_handle); | 257 CSSM_DeleteContext(cc_handle); |
254 return err; | 258 return err; |
255 } | 259 } |
256 | 260 |
257 } // namespace net | 261 } // namespace net |
OLD | NEW |