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 enum SignatureHashAlgorithm { |
| 84 kSignatureHashAlgorithmMd2, |
| 85 kSignatureHashAlgorithmMd4, |
| 86 kSignatureHashAlgorithmMd5, |
| 87 kSignatureHashAlgorithmSha1, |
| 88 kSignatureHashAlgorithmOther, |
| 89 }; |
| 90 |
83 enum Format { | 91 enum Format { |
84 // The data contains a single DER-encoded certificate, or a PEM-encoded | 92 // The data contains a single DER-encoded certificate, or a PEM-encoded |
85 // DER certificate with the PEM encoding block name of "CERTIFICATE". | 93 // DER certificate with the PEM encoding block name of "CERTIFICATE". |
86 // Any subsequent blocks will be ignored. | 94 // Any subsequent blocks will be ignored. |
87 FORMAT_SINGLE_CERTIFICATE = 1 << 0, | 95 FORMAT_SINGLE_CERTIFICATE = 1 << 0, |
88 | 96 |
89 // The data contains a sequence of one or more PEM-encoded, DER | 97 // The data contains a sequence of one or more PEM-encoded, DER |
90 // certificates, with the PEM encoding block name of "CERTIFICATE". | 98 // certificates, with the PEM encoding block name of "CERTIFICATE". |
91 // All PEM blocks will be parsed, until the first error is encountered. | 99 // All PEM blocks will be parsed, until the first error is encountered. |
92 FORMAT_PEM_CERT_SEQUENCE = 1 << 1, | 100 FORMAT_PEM_CERT_SEQUENCE = 1 << 1, |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // the first element. | 328 // the first element. |
321 bool GetPEMEncodedChain(std::vector<std::string>* pem_encoded) const; | 329 bool GetPEMEncodedChain(std::vector<std::string>* pem_encoded) const; |
322 | 330 |
323 // Sets |*size_bits| to be the length of the public key in bits, and sets | 331 // 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 | 332 // |*type| to one of the |PublicKeyType| values. In case of |
325 // |kPublicKeyTypeUnknown|, |*size_bits| will be set to 0. | 333 // |kPublicKeyTypeUnknown|, |*size_bits| will be set to 0. |
326 static void GetPublicKeyInfo(OSCertHandle cert_handle, | 334 static void GetPublicKeyInfo(OSCertHandle cert_handle, |
327 size_t* size_bits, | 335 size_t* size_bits, |
328 PublicKeyType* type); | 336 PublicKeyType* type); |
329 | 337 |
| 338 // Returns the digest algorithm used in |cert_handle|'s signature. |
| 339 // If the digest algorithm cannot be determined, or if it is not one |
| 340 // of the explicitly enumerated values, kSignatureHashAlgorithmOther |
| 341 // will be returned. |
| 342 // NOTE: No validation of the signature is performed, and thus invalid |
| 343 // signatures may result in seemingly meaningful values. |
| 344 static SignatureHashAlgorithm GetSignatureHashAlgorithm( |
| 345 OSCertHandle cert_handle); |
| 346 |
330 // Returns the OSCertHandle of this object. Because of caching, this may | 347 // Returns the OSCertHandle of this object. Because of caching, this may |
331 // differ from the OSCertHandle originally supplied during initialization. | 348 // differ from the OSCertHandle originally supplied during initialization. |
332 // Note: On Windows, CryptoAPI may return unexpected results if this handle | 349 // Note: On Windows, CryptoAPI may return unexpected results if this handle |
333 // is used across multiple threads. For more details, see | 350 // is used across multiple threads. For more details, see |
334 // CreateOSCertChainForCert(). | 351 // CreateOSCertChainForCert(). |
335 OSCertHandle os_cert_handle() const { return cert_handle_; } | 352 OSCertHandle os_cert_handle() const { return cert_handle_; } |
336 | 353 |
337 // Returns true if two OSCertHandles refer to identical certificates. | 354 // Returns true if two OSCertHandles refer to identical certificates. |
338 static bool IsSameOSCert(OSCertHandle a, OSCertHandle b); | 355 static bool IsSameOSCert(OSCertHandle a, OSCertHandle b); |
339 | 356 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 // based on the type of the certificate. | 485 // based on the type of the certificate. |
469 std::string default_nickname_; | 486 std::string default_nickname_; |
470 #endif | 487 #endif |
471 | 488 |
472 DISALLOW_COPY_AND_ASSIGN(X509Certificate); | 489 DISALLOW_COPY_AND_ASSIGN(X509Certificate); |
473 }; | 490 }; |
474 | 491 |
475 } // namespace net | 492 } // namespace net |
476 | 493 |
477 #endif // NET_CERT_X509_CERTIFICATE_H_ | 494 #endif // NET_CERT_X509_CERTIFICATE_H_ |
OLD | NEW |