Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: net/cert/sha256_legacy_support_nss_win.cc

Issue 687833002: Get net_unittests working on Windows BoringSSL port. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wincrypt
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/cert/sha256_legacy_support_win.h"
6
7 #include <cert.h> 5 #include <cert.h>
8 #include <keyhi.h> 6 #include <keyhi.h>
9 #include <secoid.h> 7 #include <secoid.h>
10 8
11 #include "base/lazy_instance.h"
12 #include "base/logging.h" 9 #include "base/logging.h"
13 #include "base/strings/string_piece.h"
14 #include "base/win/windows_version.h"
15 #include "crypto/scoped_nss_types.h" 10 #include "crypto/scoped_nss_types.h"
11 #include "net/cert/sha256_legacy_support_win.h"
16 12
17 namespace net { 13 namespace net {
18 14
19 namespace sha256_interception { 15 namespace sha256_interception {
20 16
21 namespace {
22
23 bool IsSupportedSubjectType(DWORD subject_type) {
24 switch (subject_type) {
25 case CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB:
26 case CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT:
27 case CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL:
28 return true;
29 }
30 return false;
31 }
32
33 bool IsSupportedIssuerType(DWORD issuer_type) {
34 switch (issuer_type) {
35 case CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY:
36 case CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT:
37 case CRYPT_VERIFY_CERT_SIGN_ISSUER_CHAIN:
38 return true;
39 }
40 return false;
41 }
42
43 base::StringPiece GetSubjectSignature(DWORD subject_type,
44 void* subject_data) {
45 switch (subject_type) {
46 case CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB: {
47 CRYPT_DATA_BLOB* data_blob =
48 reinterpret_cast<CRYPT_DATA_BLOB*>(subject_data);
49 return base::StringPiece(reinterpret_cast<char*>(data_blob->pbData),
50 data_blob->cbData);
51 }
52 case CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT: {
53 PCCERT_CONTEXT subject_cert =
54 reinterpret_cast<PCCERT_CONTEXT>(subject_data);
55 return base::StringPiece(
56 reinterpret_cast<char*>(subject_cert->pbCertEncoded),
57 subject_cert->cbCertEncoded);
58 }
59 case CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL: {
60 PCCRL_CONTEXT subject_crl =
61 reinterpret_cast<PCCRL_CONTEXT>(subject_data);
62 return base::StringPiece(
63 reinterpret_cast<char*>(subject_crl->pbCrlEncoded),
64 subject_crl->cbCrlEncoded);
65 }
66 }
67 return base::StringPiece();
68 }
69
70 PCERT_PUBLIC_KEY_INFO GetIssuerPublicKey(DWORD issuer_type,
71 void* issuer_data) {
72 switch (issuer_type) {
73 case CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY:
74 return reinterpret_cast<PCERT_PUBLIC_KEY_INFO>(issuer_data);
75 case CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT: {
76 PCCERT_CONTEXT cert = reinterpret_cast<PCCERT_CONTEXT>(issuer_data);
77 return &cert->pCertInfo->SubjectPublicKeyInfo;
78 }
79 case CRYPT_VERIFY_CERT_SIGN_ISSUER_CHAIN: {
80 PCCERT_CHAIN_CONTEXT chain =
81 reinterpret_cast<PCCERT_CHAIN_CONTEXT>(issuer_data);
82 PCCERT_CONTEXT cert = chain->rgpChain[0]->rgpElement[0]->pCertContext;
83 return &cert->pCertInfo->SubjectPublicKeyInfo;
84 }
85 }
86 return NULL;
87 }
88
89 } // namespace
90
91 BOOL CryptVerifyCertificateSignatureExHook( 17 BOOL CryptVerifyCertificateSignatureExHook(
92 CryptVerifyCertificateSignatureExFunc original_func, 18 CryptVerifyCertificateSignatureExFunc original_func,
93 HCRYPTPROV_LEGACY provider, 19 HCRYPTPROV_LEGACY provider,
94 DWORD encoding_type, 20 DWORD encoding_type,
95 DWORD subject_type, 21 DWORD subject_type,
96 void* subject_data, 22 void* subject_data,
97 DWORD issuer_type, 23 DWORD issuer_type,
98 void* issuer_data, 24 void* issuer_data,
99 DWORD flags, 25 DWORD flags,
100 void* extra) { 26 void* extra) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (rv != SECSuccess) { 109 if (rv != SECSuccess) {
184 SetLastError(static_cast<DWORD>(NTE_BAD_SIGNATURE)); 110 SetLastError(static_cast<DWORD>(NTE_BAD_SIGNATURE));
185 return FALSE; 111 return FALSE;
186 } 112 }
187 return TRUE; 113 return TRUE;
188 } 114 }
189 115
190 } // namespace sha256_interception 116 } // namespace sha256_interception
191 117
192 } // namespace net 118 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698