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 <keyhi.h> |
10 #include <nss.h> | 10 #include <nss.h> |
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1135 } | 1135 } |
1136 | 1136 |
1137 // static | 1137 // static |
1138 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, | 1138 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, |
1139 Pickle* pickle) { | 1139 Pickle* pickle) { |
1140 return pickle->WriteData( | 1140 return pickle->WriteData( |
1141 reinterpret_cast<const char*>(cert_handle->derCert.data), | 1141 reinterpret_cast<const char*>(cert_handle->derCert.data), |
1142 cert_handle->derCert.len); | 1142 cert_handle->derCert.len); |
1143 } | 1143 } |
1144 | 1144 |
1145 // static | |
1146 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, | |
1147 size_t* size_bits, | |
1148 PublicKeyType* type) { | |
1149 SECKEYPublicKey* key = CERT_ExtractPublicKey(cert_handle); | |
Ryan Sleevi
2011/12/13 23:54:16
Can this fail? Do we care?
| |
1150 *size_bits = SECKEY_PublicKeyStrengthInBits(key); | |
1151 | |
1152 switch (key->keyType) { | |
1153 case rsaKey: | |
1154 *type = kPublicKeyTypeRSA; | |
1155 break; | |
1156 case dsaKey: | |
1157 *type = kPublicKeyTypeDSA; | |
1158 break; | |
1159 case dhKey: | |
1160 *type = kPublicKeyTypeDH; | |
1161 break; | |
1162 case ecKey: | |
1163 *type = kPublicKeyTypeECDSA; | |
1164 break; | |
1165 default: | |
1166 *type = kPublicKeyTypeUnknown; | |
1167 *size_bits = 0; | |
1168 break; | |
1169 } | |
1170 } | |
1171 | |
1145 } // namespace net | 1172 } // namespace net |
OLD | NEW |