Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Unified Diff: net/base/keygen_handler_win.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/base/keygen_handler_win.cc
diff --git a/net/base/keygen_handler_win.cc b/net/base/keygen_handler_win.cc
index 59dc69de54c104a2874106194cb310e6d88479a3..476bc69c03f774b7bb40148e9970413671cfb88a 100644
--- a/net/base/keygen_handler_win.cc
+++ b/net/base/keygen_handler_win.cc
@@ -23,7 +23,6 @@
#include "crypto/capi_util.h"
#include "crypto/scoped_capi_types.h"
-
namespace net {
// Assigns the contents of a CERT_PUBLIC_KEY_INFO structure for the signing
@@ -35,8 +34,14 @@ bool GetSubjectPublicKeyInfo(HCRYPTPROV prov, std::vector<BYTE>* output) {
// From the private key stored in HCRYPTPROV, obtain the public key, stored
// as a CERT_PUBLIC_KEY_INFO structure. Currently, only RSA public keys are
// supported.
- ok = CryptExportPublicKeyInfoEx(prov, AT_KEYEXCHANGE, X509_ASN_ENCODING,
- szOID_RSA_RSA, 0, NULL, NULL, &size);
+ ok = CryptExportPublicKeyInfoEx(prov,
+ AT_KEYEXCHANGE,
+ X509_ASN_ENCODING,
+ szOID_RSA_RSA,
+ 0,
+ NULL,
+ NULL,
+ &size);
DCHECK(ok);
if (!ok)
return false;
@@ -45,8 +50,13 @@ bool GetSubjectPublicKeyInfo(HCRYPTPROV prov, std::vector<BYTE>* output) {
PCERT_PUBLIC_KEY_INFO public_key_casted =
reinterpret_cast<PCERT_PUBLIC_KEY_INFO>(&(*output)[0]);
- ok = CryptExportPublicKeyInfoEx(prov, AT_KEYEXCHANGE, X509_ASN_ENCODING,
- szOID_RSA_RSA, 0, NULL, public_key_casted,
+ ok = CryptExportPublicKeyInfoEx(prov,
+ AT_KEYEXCHANGE,
+ X509_ASN_ENCODING,
+ szOID_RSA_RSA,
+ 0,
+ NULL,
+ public_key_casted,
&size);
DCHECK(ok);
if (!ok)
@@ -87,19 +97,29 @@ bool GetSignedPublicKeyAndChallenge(HCRYPTPROV prov,
BOOL ok;
DWORD size = 0;
std::vector<BYTE> signed_pkac;
- ok = CryptSignAndEncodeCertificate(prov, AT_KEYEXCHANGE, X509_ASN_ENCODING,
+ ok = CryptSignAndEncodeCertificate(prov,
+ AT_KEYEXCHANGE,
+ X509_ASN_ENCODING,
X509_KEYGEN_REQUEST_TO_BE_SIGNED,
- &pkac, &sig_alg, NULL,
- NULL, &size);
+ &pkac,
+ &sig_alg,
+ NULL,
+ NULL,
+ &size);
DCHECK(ok);
if (!ok)
return false;
signed_pkac.resize(size);
- ok = CryptSignAndEncodeCertificate(prov, AT_KEYEXCHANGE, X509_ASN_ENCODING,
+ ok = CryptSignAndEncodeCertificate(prov,
+ AT_KEYEXCHANGE,
+ X509_ASN_ENCODING,
X509_KEYGEN_REQUEST_TO_BE_SIGNED,
- &pkac, &sig_alg, NULL,
- &signed_pkac[0], &size);
+ &pkac,
+ &sig_alg,
+ NULL,
+ &signed_pkac[0],
+ &size);
DCHECK(ok);
if (!ok)
return false;
@@ -114,7 +134,7 @@ std::wstring GetNewKeyContainerId() {
RPC_STATUS status = RPC_S_OK;
std::wstring result;
- UUID id = { 0 };
+ UUID id = {0};
status = UuidCreateSequential(&id);
if (status != RPC_S_OK && status != RPC_S_UUID_LOCAL_ONLY)
return result;
@@ -136,16 +156,18 @@ std::wstring GetNewKeyContainerId() {
// the associated provider.
struct KeyContainer {
public:
- explicit KeyContainer(bool delete_keyset)
- : delete_keyset_(delete_keyset) {}
+ explicit KeyContainer(bool delete_keyset) : delete_keyset_(delete_keyset) {}
~KeyContainer() {
if (provider_) {
provider_.reset();
if (delete_keyset_ && !key_id_.empty()) {
HCRYPTPROV provider;
- crypto::CryptAcquireContextLocked(&provider, key_id_.c_str(), NULL,
- PROV_RSA_FULL, CRYPT_SILENT | CRYPT_DELETEKEYSET);
+ crypto::CryptAcquireContextLocked(&provider,
+ key_id_.c_str(),
+ NULL,
+ PROV_RSA_FULL,
+ CRYPT_SILENT | CRYPT_DELETEKEYSET);
}
}
}
@@ -178,8 +200,10 @@ std::string KeygenHandler::GenKeyAndSignChallenge() {
// Only create new key containers, so that existing key containers are not
// overwritten.
if (crypto::CryptAcquireContextLocked(key_container.provider_.receive(),
- key_container.key_id_.c_str(), NULL, PROV_RSA_FULL,
- CRYPT_SILENT | CRYPT_NEWKEYSET))
+ key_container.key_id_.c_str(),
+ NULL,
+ PROV_RSA_FULL,
+ CRYPT_SILENT | CRYPT_NEWKEYSET))
break;
if (GetLastError() != NTE_BAD_KEYSET) {
@@ -196,15 +220,17 @@ std::string KeygenHandler::GenKeyAndSignChallenge() {
{
crypto::ScopedHCRYPTKEY key;
- if (!CryptGenKey(key_container.provider_, CALG_RSA_KEYX,
- (key_size_in_bits_ << 16) | CRYPT_EXPORTABLE, key.receive())) {
+ if (!CryptGenKey(key_container.provider_,
+ CALG_RSA_KEYX,
+ (key_size_in_bits_ << 16) | CRYPT_EXPORTABLE,
+ key.receive())) {
LOG(ERROR) << "Keygen failed: Couldn't generate an RSA key";
return std::string();
}
std::string spkac;
- if (!GetSignedPublicKeyAndChallenge(key_container.provider_, challenge_,
- &spkac)) {
+ if (!GetSignedPublicKeyAndChallenge(
+ key_container.provider_, challenge_, &spkac)) {
LOG(ERROR) << "Keygen failed: Couldn't generate the signed public key "
"and challenge";
return std::string();

Powered by Google App Engine
This is Rietveld 408576698