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 <nss.h> | 9 #include <nss.h> |
10 #include <pk11pub.h> | 10 #include <pk11pub.h> |
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 } | 1038 } |
1039 | 1039 |
1040 // static | 1040 // static |
1041 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, | 1041 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, |
1042 Pickle* pickle) { | 1042 Pickle* pickle) { |
1043 return pickle->WriteData( | 1043 return pickle->WriteData( |
1044 reinterpret_cast<const char*>(cert_handle->derCert.data), | 1044 reinterpret_cast<const char*>(cert_handle->derCert.data), |
1045 cert_handle->derCert.len); | 1045 cert_handle->derCert.len); |
1046 } | 1046 } |
1047 | 1047 |
| 1048 //static |
| 1049 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, |
| 1050 size_t* size_bits, |
| 1051 PublicKeyType* type) { |
| 1052 SECKEYPublicKey* key = CERT_ExtractPublicKey(cert_handle); |
| 1053 *size_bits = SECKEY_PublicKeyStrengthInBits(key); |
| 1054 |
| 1055 switch (key->keyType) { |
| 1056 case rsaKey: |
| 1057 *type = PublicKeyType::RSA; |
| 1058 break; |
| 1059 case dsaKey: |
| 1060 *type = PublicKeyType::DSA; |
| 1061 break; |
| 1062 case dhKey: |
| 1063 *type = PublicKeyType::DH; |
| 1064 break; |
| 1065 case ecKey: |
| 1066 *type = PublicKeyType::ECDSA; |
| 1067 break; |
| 1068 default: |
| 1069 *type = PublicKeyType::NONE; |
| 1070 } |
| 1071 } |
| 1072 |
1048 } // namespace net | 1073 } // namespace net |
OLD | NEW |