OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/x509_certificate.h" | 5 #include "net/base/x509_certificate.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 #include <cryptohi.h> | 8 #include <cryptohi.h> |
| 9 #include <keyhi.h> |
9 #include <nss.h> | 10 #include <nss.h> |
10 #include <pk11pub.h> | 11 #include <pk11pub.h> |
11 #include <prerror.h> | 12 #include <prerror.h> |
12 #include <prtime.h> | 13 #include <prtime.h> |
13 #include <secder.h> | 14 #include <secder.h> |
14 #include <secerr.h> | 15 #include <secerr.h> |
15 #include <sechash.h> | 16 #include <sechash.h> |
16 #include <sslerr.h> | 17 #include <sslerr.h> |
17 | 18 |
18 #include "base/logging.h" | 19 #include "base/logging.h" |
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 } | 1039 } |
1039 | 1040 |
1040 // static | 1041 // static |
1041 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, | 1042 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, |
1042 Pickle* pickle) { | 1043 Pickle* pickle) { |
1043 return pickle->WriteData( | 1044 return pickle->WriteData( |
1044 reinterpret_cast<const char*>(cert_handle->derCert.data), | 1045 reinterpret_cast<const char*>(cert_handle->derCert.data), |
1045 cert_handle->derCert.len); | 1046 cert_handle->derCert.len); |
1046 } | 1047 } |
1047 | 1048 |
| 1049 // static |
| 1050 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, |
| 1051 size_t* size_bits, |
| 1052 PublicKeyType* type) { |
| 1053 SECKEYPublicKey* key = CERT_ExtractPublicKey(cert_handle); |
| 1054 *size_bits = SECKEY_PublicKeyStrengthInBits(key); |
| 1055 |
| 1056 switch (key->keyType) { |
| 1057 case rsaKey: |
| 1058 *type = kPublicKeyTypeRSA; |
| 1059 break; |
| 1060 case dsaKey: |
| 1061 *type = kPublicKeyTypeDSA; |
| 1062 break; |
| 1063 case dhKey: |
| 1064 *type = kPublicKeyTypeDH; |
| 1065 break; |
| 1066 case ecKey: |
| 1067 *type = kPublicKeyTypeECDSA; |
| 1068 break; |
| 1069 default: |
| 1070 *type = kPublicKeyTypeUnknown; |
| 1071 } |
| 1072 } |
| 1073 |
1048 } // namespace net | 1074 } // namespace net |
OLD | NEW |