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 CHROMEOS_NETWORK_CLIENT_CERT_UTIL_H_ | 5 #ifndef CHROMEOS_NETWORK_CLIENT_CERT_UTIL_H_ |
6 #define CHROMEOS_NETWORK_CLIENT_CERT_UTIL_H_ | 6 #define CHROMEOS_NETWORK_CLIENT_CERT_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 CertificatePattern pattern; | 48 CertificatePattern pattern; |
49 }; | 49 }; |
50 | 50 |
51 // Returns true only if any fields set in this pattern match exactly with | 51 // Returns true only if any fields set in this pattern match exactly with |
52 // similar fields in the principal. If organization_ or organizational_unit_ | 52 // similar fields in the principal. If organization_ or organizational_unit_ |
53 // are set, then at least one of the organizations or units in the principal | 53 // are set, then at least one of the organizations or units in the principal |
54 // must match. | 54 // must match. |
55 bool CertPrincipalMatches(const IssuerSubjectPattern& pattern, | 55 bool CertPrincipalMatches(const IssuerSubjectPattern& pattern, |
56 const net::CertPrincipal& principal); | 56 const net::CertPrincipal& principal); |
57 | 57 |
58 // Returns the PKCS11 id part of |cert_id|, which is expected to be the value of | 58 // Returns the PKCS11 and slot ID of |cert_id|, which is expected to be a |
59 // the Shill property kEapCertIdProperty or kEapKeyIdProperty. | 59 // value of the Shill property kEapCertIdProperty or kEapKeyIdProperty, either |
60 CHROMEOS_EXPORT std::string GetPkcs11IdFromEapCertId( | 60 // of format "<pkcs11_id>" or "<slot_id>:<pkcs11_id>". |
61 const std::string& cert_id); | 61 CHROMEOS_EXPORT std::string GetPkcs11AndSlotIdFromEapCertId( |
| 62 const std::string& cert_id, |
| 63 int* slot_id); |
| 64 |
| 65 // Reads the client certificate configuration from the Shill Service properties |
| 66 // |shill_properties|. |
| 67 // If such a configuration is found, the values |cert_config_type|, |tpm_slot| |
| 68 // and |pkcs11_id| are filled accordingly. In case of OpenVPN or because the |
| 69 // property was not set, |tpm_slot| will be set to -1. |
| 70 // If an error occurred or no client configuration is found, |cert_config_type| |
| 71 // will be set to CONFIG_TYPE_NONE, |tpm_slot| to -1 and |pkcs11_id| to the |
| 72 // empty string. |
| 73 CHROMEOS_EXPORT void GetClientCertFromShillProperties( |
| 74 const base::DictionaryValue& shill_properties, |
| 75 ConfigType* cert_config_type, |
| 76 int* tpm_slot, |
| 77 std::string* pkcs11_id); |
62 | 78 |
63 // Sets the properties of a client cert and the TPM slot that it's contained in. | 79 // Sets the properties of a client cert and the TPM slot that it's contained in. |
64 // |cert_config_type| determines which dictionary entries to set. | 80 // |cert_config_type| determines which dictionary entries to set. |
65 CHROMEOS_EXPORT void SetShillProperties(const ConfigType cert_config_type, | 81 CHROMEOS_EXPORT void SetShillProperties(const ConfigType cert_config_type, |
66 const int tpm_slot, | 82 const int tpm_slot, |
67 const std::string& pkcs11_id, | 83 const std::string& pkcs11_id, |
68 base::DictionaryValue* properties); | 84 base::DictionaryValue* properties); |
69 | 85 |
70 // Like SetShillProperties but instead sets the properties to empty strings. | 86 // Like SetShillProperties but instead sets the properties to empty strings. |
71 // This should be used to clear previously set client certificate properties. | 87 // This should be used to clear previously set client certificate properties. |
72 CHROMEOS_EXPORT void SetEmptyShillProperties(const ConfigType cert_config_type, | 88 CHROMEOS_EXPORT void SetEmptyShillProperties(const ConfigType cert_config_type, |
73 base::DictionaryValue* properties); | 89 base::DictionaryValue* properties); |
74 | 90 |
75 // Returns true if all required configuration properties are set and not empty. | 91 // Returns true if all required configuration properties are set and not empty. |
76 bool IsCertificateConfigured(const client_cert::ConfigType cert_config_type, | 92 bool IsCertificateConfigured(const client_cert::ConfigType cert_config_type, |
77 const base::DictionaryValue& service_properties); | 93 const base::DictionaryValue& service_properties); |
78 | 94 |
79 // Determines the type of the CertificatePattern configuration, i.e. is it a | 95 // Determines the type of the CertificatePattern configuration, i.e. is it a |
80 // pattern within an EAP, IPsec or OpenVPN configuration. | 96 // pattern within an EAP, IPsec or OpenVPN configuration. |
81 CHROMEOS_EXPORT void OncToClientCertConfig( | 97 CHROMEOS_EXPORT void OncToClientCertConfig( |
82 const base::DictionaryValue& network_config, | 98 const base::DictionaryValue& network_config, |
83 ClientCertConfig* cert_config); | 99 ClientCertConfig* cert_config); |
84 | 100 |
85 } // namespace client_cert | 101 } // namespace client_cert |
86 | 102 |
87 } // namespace chromeos | 103 } // namespace chromeos |
88 | 104 |
89 #endif // CHROMEOS_NETWORK_CLIENT_CERT_UTIL_H_ | 105 #endif // CHROMEOS_NETWORK_CLIENT_CERT_UTIL_H_ |
OLD | NEW |