Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef NET_CERT_X509_CERTIFICATE_H_ | 5 #ifndef NET_CERT_X509_CERTIFICATE_H_ |
| 6 #define NET_CERT_X509_CERTIFICATE_H_ | 6 #define NET_CERT_X509_CERTIFICATE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 | 73 |
| 74 enum PublicKeyType { | 74 enum PublicKeyType { |
| 75 kPublicKeyTypeUnknown, | 75 kPublicKeyTypeUnknown, |
| 76 kPublicKeyTypeRSA, | 76 kPublicKeyTypeRSA, |
| 77 kPublicKeyTypeDSA, | 77 kPublicKeyTypeDSA, |
| 78 kPublicKeyTypeECDSA, | 78 kPublicKeyTypeECDSA, |
| 79 kPublicKeyTypeDH, | 79 kPublicKeyTypeDH, |
| 80 kPublicKeyTypeECDH | 80 kPublicKeyTypeECDH |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 // Enumeration for weak hashing algorithms. | |
|
Ryan Sleevi
2017/01/05 22:48:24
This feels very much like a tighter coupling.
Tha
eroman
2017/01/05 23:21:53
Sure, I will remove the comment about it being "we
eroman
2017/01/05 23:36:30
Done.
| |
| 84 enum SignatureHashAlgorithm { | |
| 85 kSignatureHashAlgorithmMd2, | |
| 86 kSignatureHashAlgorithmMd4, | |
| 87 kSignatureHashAlgorithmMd5, | |
| 88 kSignatureHashAlgorithmSha1, | |
| 89 kSignatureHashAlgorithmOther, | |
| 90 }; | |
| 91 | |
| 83 enum Format { | 92 enum Format { |
| 84 // The data contains a single DER-encoded certificate, or a PEM-encoded | 93 // The data contains a single DER-encoded certificate, or a PEM-encoded |
| 85 // DER certificate with the PEM encoding block name of "CERTIFICATE". | 94 // DER certificate with the PEM encoding block name of "CERTIFICATE". |
| 86 // Any subsequent blocks will be ignored. | 95 // Any subsequent blocks will be ignored. |
| 87 FORMAT_SINGLE_CERTIFICATE = 1 << 0, | 96 FORMAT_SINGLE_CERTIFICATE = 1 << 0, |
| 88 | 97 |
| 89 // The data contains a sequence of one or more PEM-encoded, DER | 98 // The data contains a sequence of one or more PEM-encoded, DER |
| 90 // certificates, with the PEM encoding block name of "CERTIFICATE". | 99 // certificates, with the PEM encoding block name of "CERTIFICATE". |
| 91 // All PEM blocks will be parsed, until the first error is encountered. | 100 // All PEM blocks will be parsed, until the first error is encountered. |
| 92 FORMAT_PEM_CERT_SEQUENCE = 1 << 1, | 101 FORMAT_PEM_CERT_SEQUENCE = 1 << 1, |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 // the first element. | 329 // the first element. |
| 321 bool GetPEMEncodedChain(std::vector<std::string>* pem_encoded) const; | 330 bool GetPEMEncodedChain(std::vector<std::string>* pem_encoded) const; |
| 322 | 331 |
| 323 // Sets |*size_bits| to be the length of the public key in bits, and sets | 332 // Sets |*size_bits| to be the length of the public key in bits, and sets |
| 324 // |*type| to one of the |PublicKeyType| values. In case of | 333 // |*type| to one of the |PublicKeyType| values. In case of |
| 325 // |kPublicKeyTypeUnknown|, |*size_bits| will be set to 0. | 334 // |kPublicKeyTypeUnknown|, |*size_bits| will be set to 0. |
| 326 static void GetPublicKeyInfo(OSCertHandle cert_handle, | 335 static void GetPublicKeyInfo(OSCertHandle cert_handle, |
| 327 size_t* size_bits, | 336 size_t* size_bits, |
| 328 PublicKeyType* type); | 337 PublicKeyType* type); |
| 329 | 338 |
| 339 // Returns the hashing algorithm used by |cert_handle|. If the hashing | |
| 340 // algorithm is NOT one of the enumerated weak ones, OR the implementation | |
| 341 // fails, then will return kSignatureHashAlgorithmOther. | |
|
Ryan Sleevi
2017/01/05 22:48:24
// Returns the digest algorithm used in |cert_hand
eroman
2017/01/05 23:36:30
Done.
| |
| 342 static SignatureHashAlgorithm GetSignatureHashAlgorithm( | |
| 343 OSCertHandle cert_handle); | |
| 344 | |
| 330 // Returns the OSCertHandle of this object. Because of caching, this may | 345 // Returns the OSCertHandle of this object. Because of caching, this may |
| 331 // differ from the OSCertHandle originally supplied during initialization. | 346 // differ from the OSCertHandle originally supplied during initialization. |
| 332 // Note: On Windows, CryptoAPI may return unexpected results if this handle | 347 // Note: On Windows, CryptoAPI may return unexpected results if this handle |
| 333 // is used across multiple threads. For more details, see | 348 // is used across multiple threads. For more details, see |
| 334 // CreateOSCertChainForCert(). | 349 // CreateOSCertChainForCert(). |
| 335 OSCertHandle os_cert_handle() const { return cert_handle_; } | 350 OSCertHandle os_cert_handle() const { return cert_handle_; } |
| 336 | 351 |
| 337 // Returns true if two OSCertHandles refer to identical certificates. | 352 // Returns true if two OSCertHandles refer to identical certificates. |
| 338 static bool IsSameOSCert(OSCertHandle a, OSCertHandle b); | 353 static bool IsSameOSCert(OSCertHandle a, OSCertHandle b); |
| 339 | 354 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 // based on the type of the certificate. | 483 // based on the type of the certificate. |
| 469 std::string default_nickname_; | 484 std::string default_nickname_; |
| 470 #endif | 485 #endif |
| 471 | 486 |
| 472 DISALLOW_COPY_AND_ASSIGN(X509Certificate); | 487 DISALLOW_COPY_AND_ASSIGN(X509Certificate); |
| 473 }; | 488 }; |
| 474 | 489 |
| 475 } // namespace net | 490 } // namespace net |
| 476 | 491 |
| 477 #endif // NET_CERT_X509_CERTIFICATE_H_ | 492 #endif // NET_CERT_X509_CERTIFICATE_H_ |
| OLD | NEW |