| OLD | NEW |
| 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 <openssl/asn1.h> | 5 #include <openssl/asn1.h> |
| 6 #include <openssl/bytestring.h> | 6 #include <openssl/bytestring.h> |
| 7 #include <openssl/evp.h> | 7 #include <openssl/evp.h> |
| 8 #include <openssl/obj.h> | 8 #include <openssl/obj.h> |
| 9 #include <openssl/x509.h> | 9 #include <openssl/x509.h> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "crypto/scoped_openssl_types.h" | 12 #include "crypto/scoped_openssl_types.h" |
| 13 #include "net/cert/sha256_legacy_support_win.h" | 13 #include "net/cert/sha256_legacy_support_win.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 namespace sha256_interception { | 17 namespace sha256_interception { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 typedef crypto::ScopedOpenSSL<X509_ALGOR, X509_ALGOR_free>::Type | 21 using ScopedX509_ALGOR = crypto::ScopedOpenSSL<X509_ALGOR, X509_ALGOR_free>; |
| 22 ScopedX509_ALGOR; | |
| 23 | 22 |
| 24 // Parses |subject_signature| and writes the components into |*out_tbs_data|, | 23 // Parses |subject_signature| and writes the components into |*out_tbs_data|, |
| 25 // |*out_algor|, and |*out_signature|. The BIT STRING in the signature must be | 24 // |*out_algor|, and |*out_signature|. The BIT STRING in the signature must be |
| 26 // a multiple of 8 bits. |*out_signature| will have the padding byte removed. | 25 // a multiple of 8 bits. |*out_signature| will have the padding byte removed. |
| 27 // It returns true on success and false on failure. | 26 // It returns true on success and false on failure. |
| 28 bool ParseSubjectSignature(const base::StringPiece& subject_signature, | 27 bool ParseSubjectSignature(const base::StringPiece& subject_signature, |
| 29 CBS* out_tbs_data, | 28 CBS* out_tbs_data, |
| 30 ScopedX509_ALGOR* out_algor, | 29 ScopedX509_ALGOR* out_algor, |
| 31 CBS* out_signature) { | 30 CBS* out_signature) { |
| 32 CBS cbs, sequence, tbs_data, algorithm, signature; | 31 CBS cbs, sequence, tbs_data, algorithm, signature; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 !EVP_DigestVerifyFinal(md_ctx.get(), CBS_data(&signature), | 143 !EVP_DigestVerifyFinal(md_ctx.get(), CBS_data(&signature), |
| 145 CBS_len(&signature))) { | 144 CBS_len(&signature))) { |
| 146 SetLastError(static_cast<DWORD>(NTE_BAD_SIGNATURE)); | 145 SetLastError(static_cast<DWORD>(NTE_BAD_SIGNATURE)); |
| 147 return FALSE; | 146 return FALSE; |
| 148 } | 147 } |
| 149 return TRUE; | 148 return TRUE; |
| 150 } | 149 } |
| 151 | 150 |
| 152 } // namespace sha256_interception | 151 } // namespace sha256_interception |
| 153 | 152 |
| 154 } // namespace net | 153 } // namespace net |
| OLD | NEW |