Index: net/base/x509_certificate_win.cc |
=================================================================== |
--- net/base/x509_certificate_win.cc (revision 110129) |
+++ net/base/x509_certificate_win.cc (working copy) |
@@ -1153,4 +1153,35 @@ |
length); |
} |
+//static |
+void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, |
+ size_t* size_bits, |
+ PublicKeyType* type) { |
+ *size_bits = CertGetPublicKeyLength( |
+ X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, |
+ cert_handle->pCertInfo->SubjectPublicKeyInfo); |
+ |
+ PCCRYPT_OID_INFO oid_info = CryptFindOIDInfo( |
+ CRYPT_OID_INFO_OID_KEY, |
+ cert_handle->pCertInfo->SubjectPublicKeyInfo->Algorithm->pszObjId, |
+ CRYPT_SIGN_ALG_OID_GROUP_ID); |
+ CHECK(CRYPT_OID_INFO.dwGroupId == CRYPT_SIGN_ALG_OID_GROUP_ID); |
Ryan Sleevi
2011/11/16 03:46:11
nit: oid_info->dwGroupId (and the next two lines)
|
+ CHECK(CRYPT_OID_INFO.ExtraInfo.cbData >= sizeof(DWORD)); |
+ DWORD id = *reinterpret_cast<DWORD*>(CRYPT_OID_INFO.ExtraInfo.pbData); |
+ |
+ switch (id) { |
+ case CALG_RSA_SIGN: |
+ *type = PublicKeyType::RSA; |
+ break; |
+ case CALG_DSS_SIGN: |
+ *type = PublicKeyType::DSA; |
+ break; |
+ case CALG_ECDSA: |
+ *type = PublicKeyType::ECDSA; |
+ break; |
+ default: |
+ *type = PublicKeyType::None; |
+ } |
+} |
+ |
} // namespace net |