Chromium Code Reviews| Index: net/cert/x509_util.h |
| =================================================================== |
| --- net/cert/x509_util.h (revision 229411) |
| +++ net/cert/x509_util.h (working copy) |
| @@ -9,6 +9,7 @@ |
| #include "base/memory/ref_counted.h" |
| #include "base/time/time.h" |
| +#include "crypto/hmac.h" |
| #include "net/base/net_export.h" |
| namespace crypto { |
| @@ -30,25 +31,35 @@ |
| NET_EXPORT_PRIVATE bool IsSupportedValidityRange(base::Time not_valid_before, |
| base::Time not_valid_after); |
| -// Creates a server bound certificate containing the public key in |key|. |
| +// Creates a private keypair and server bound certificate. |
| // Domain, serial number and validity period are given as |
| // parameters. The certificate is signed by the private key in |key|. |
| -// The hashing algorithm for the signature is SHA-1. |
| +// The signature algorithm may be updated periodically to match best practices. |
| // |
| // See Internet Draft draft-balfanz-tls-obc-00 for more details: |
| // http://tools.ietf.org/html/draft-balfanz-tls-obc-00 |
| -NET_EXPORT_PRIVATE bool CreateDomainBoundCertEC( |
| +NET_EXPORT_PRIVATE bool CreateKeyAndDomainBoundCertEC( |
| + const std::string& domain, |
| + uint32 serial_number, |
| + base::Time not_valid_before, |
| + base::Time not_valid_after, |
| + crypto::ECPrivateKey** key, |
|
Ryan Sleevi
2013/10/18 22:45:23
Pass a scoped_ptr<crypto::ECPrivateKey>*, rather t
bemasc
2013/10/19 00:47:45
Done.
|
| + std::string* der_cert); |
| + |
| +// Helper function for CreateKeyAndDomainBoundCertEC |
| +NET_EXPORT_PRIVATE bool CreateDomainBoundCertECInternal( |
| crypto::ECPrivateKey* key, |
| + crypto::HMAC::HashAlgorithm alg, |
|
Ryan Sleevi
2013/10/18 22:45:23
The dependency on crypto::HMAC is wrong here.
Lik
bemasc
2013/10/19 00:47:45
I'm not sure what you mean.
Ryan Sleevi
2013/10/21 17:56:14
I meant that X.509 has nothing to do with HMAC. Yo
|
| const std::string& domain, |
| uint32 serial_number, |
| base::Time not_valid_before, |
| base::Time not_valid_after, |
| std::string* der_cert); |
| -// Create a self-signed certificate containing the public key in |key|. |
| +// Creates a public-private keypair and a self-signed certificate. |
| // Subject, serial number and validity period are given as parameters. |
| -// The certificate is signed by the private key in |key|. The hashing |
| -// algorithm for the signature is SHA-1. |
| +// The certificate is signed by the private key in |key|. The key length and |
| +// signature algorithm may be updated periodically to match best practices. |
| // |
| // |subject| is a distinguished name defined in RFC4514 with _only_ a CN |
| // component, as in: |
| @@ -62,13 +73,34 @@ |
| // 2. Self-signed certificates cannot be revoked. |
| // |
| // Use this certificate only after the above risks are acknowledged. |
| -NET_EXPORT bool CreateSelfSignedCert(crypto::RSAPrivateKey* key, |
| - const std::string& subject, |
| - uint32 serial_number, |
| - base::Time not_valid_before, |
| - base::Time not_valid_after, |
| - std::string* der_cert); |
| +NET_EXPORT bool CreateKeyAndSelfSignedCert(const std::string& subject, |
| + uint32 serial_number, |
| + base::Time not_valid_before, |
| + base::Time not_valid_after, |
| + crypto::RSAPrivateKey** key, |
|
Ryan Sleevi
2013/10/18 22:45:23
ditto scoped_ptr
bemasc
2013/10/19 00:47:45
Done.
|
| + std::string* der_cert); |
| +// Helper function for CreateKeyAndSelfSignedCert. |
| +NET_EXPORT_PRIVATE bool CreateSelfSignedCertInternal( |
| + crypto::RSAPrivateKey* key, |
| + crypto::HMAC::HashAlgorithm alg, |
| + const std::string& subject, |
| + uint32 serial_number, |
| + base::Time not_valid_before, |
| + base::Time not_valid_after, |
| + std::string* der_cert); |
| + |
| +// Legacy certificate signing function. This function is preserved here because |
| +// best practices suggest that keys signed with one hash algorithm should not be |
| +// signed again later with a different algorithm. Eventually, all users of this |
|
Ryan Sleevi
2013/10/18 22:45:23
You're not signing keys, you're signing data with
bemasc
2013/10/19 00:47:45
Done.
bemasc
2013/10/19 00:47:45
Removed this function.
|
| +// function should migrate to CreateKeyAndSelfSignedCert. |
| +NET_EXPORT bool CreateSha1SelfSignedCert(crypto::RSAPrivateKey* key, |
| + const std::string& subject, |
| + uint32 serial_number, |
| + base::Time not_valid_before, |
| + base::Time not_valid_after, |
| + std::string* der_cert); |
| + |
| // Comparator for use in STL algorithms that will sort client certificates by |
| // order of preference. |
| // Returns true if |a| is more preferable than |b|, allowing it to be used |