Compute if a layer is clipped outside CalcDrawProps
[chromium-blink-merge.git] / net / cert / sha256_legacy_support_win.cc
blob3fe700e4e1136f8a581be6fe5ad90c9569b55c85
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
3 // found in the LICENSE file.
5 #include "net/cert/sha256_legacy_support_win.h"
7 namespace net {
9 namespace sha256_interception {
11 bool IsSupportedSubjectType(DWORD subject_type) {
12 switch (subject_type) {
13 case CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB:
14 case CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT:
15 case CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL:
16 return true;
18 return false;
21 bool IsSupportedIssuerType(DWORD issuer_type) {
22 switch (issuer_type) {
23 case CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY:
24 case CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT:
25 case CRYPT_VERIFY_CERT_SIGN_ISSUER_CHAIN:
26 return true;
28 return false;
31 base::StringPiece GetSubjectSignature(DWORD subject_type,
32 void* subject_data) {
33 switch (subject_type) {
34 case CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB: {
35 CRYPT_DATA_BLOB* data_blob =
36 reinterpret_cast<CRYPT_DATA_BLOB*>(subject_data);
37 return base::StringPiece(reinterpret_cast<char*>(data_blob->pbData),
38 data_blob->cbData);
40 case CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT: {
41 PCCERT_CONTEXT subject_cert =
42 reinterpret_cast<PCCERT_CONTEXT>(subject_data);
43 return base::StringPiece(
44 reinterpret_cast<char*>(subject_cert->pbCertEncoded),
45 subject_cert->cbCertEncoded);
47 case CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL: {
48 PCCRL_CONTEXT subject_crl =
49 reinterpret_cast<PCCRL_CONTEXT>(subject_data);
50 return base::StringPiece(
51 reinterpret_cast<char*>(subject_crl->pbCrlEncoded),
52 subject_crl->cbCrlEncoded);
55 return base::StringPiece();
58 PCERT_PUBLIC_KEY_INFO GetIssuerPublicKey(DWORD issuer_type,
59 void* issuer_data) {
60 switch (issuer_type) {
61 case CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY:
62 return reinterpret_cast<PCERT_PUBLIC_KEY_INFO>(issuer_data);
63 case CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT: {
64 PCCERT_CONTEXT cert = reinterpret_cast<PCCERT_CONTEXT>(issuer_data);
65 return &cert->pCertInfo->SubjectPublicKeyInfo;
67 case CRYPT_VERIFY_CERT_SIGN_ISSUER_CHAIN: {
68 PCCERT_CHAIN_CONTEXT chain =
69 reinterpret_cast<PCCERT_CHAIN_CONTEXT>(issuer_data);
70 PCCERT_CONTEXT cert = chain->rgpChain[0]->rgpElement[0]->pCertContext;
71 return &cert->pCertInfo->SubjectPublicKeyInfo;
74 return NULL;
77 } // namespace sha256_interception
79 } // namespace net