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

Unified Diff: net/quic/crypto/aes_128_gcm_12_encrypter_nss.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/quic/crypto/aes_128_gcm_12_encrypter_nss.cc
diff --git a/net/quic/crypto/aes_128_gcm_12_encrypter_nss.cc b/net/quic/crypto/aes_128_gcm_12_encrypter_nss.cc
index 09901a4767243027aa73381c8c26fccf09513acc..7f4a33324578cea29444ee0dd0961491c99fcf1c 100644
--- a/net/quic/crypto/aes_128_gcm_12_encrypter_nss.cc
+++ b/net/quic/crypto/aes_128_gcm_12_encrypter_nss.cc
@@ -32,9 +32,7 @@ const size_t kNoncePrefixSize = 4;
// resolution of PK11_Encrypt.
class GcmSupportChecker {
public:
- static PK11_EncryptFunction pk11_encrypt_func() {
- return pk11_encrypt_func_;
- }
+ static PK11_EncryptFunction pk11_encrypt_func() { return pk11_encrypt_func_; }
private:
friend struct base::DefaultLazyInstanceTraits<GcmSupportChecker>;
@@ -49,8 +47,8 @@ class GcmSupportChecker {
// If PK11_Encrypt() was successfully resolved, then NSS will support
// AES-GCM directly. This was introduced in NSS 3.15.
- pk11_encrypt_func_ = (PK11_EncryptFunction)dlsym(RTLD_DEFAULT,
- "PK11_Encrypt");
+ pk11_encrypt_func_ =
+ (PK11_EncryptFunction)dlsym(RTLD_DEFAULT, "PK11_Encrypt");
#endif
}
@@ -79,8 +77,8 @@ SECStatus My_Encrypt(PK11SymKey* key,
PK11_EncryptFunction pk11_encrypt_func =
GcmSupportChecker::pk11_encrypt_func();
if (pk11_encrypt_func != NULL) {
- return pk11_encrypt_func(key, mechanism, param, out, out_len, max_len, data,
- data_len);
+ return pk11_encrypt_func(
+ key, mechanism, param, out, out_len, max_len, data, data_len);
}
// Otherwise, the user has an older version of NSS. Regrettably, NSS 3.14.x
@@ -110,19 +108,23 @@ SECStatus My_Encrypt(PK11SymKey* key,
return SECFailure;
}
- SECItem my_param = { siBuffer, NULL, 0 };
+ SECItem my_param = {siBuffer, NULL, 0};
// Step 1. Let H = CIPH_K(128 '0' bits).
unsigned char ghash_key[16] = {0};
- crypto::ScopedPK11Context ctx(PK11_CreateContextBySymKey(
- CKM_AES_ECB, CKA_ENCRYPT, key, &my_param));
+ crypto::ScopedPK11Context ctx(
+ PK11_CreateContextBySymKey(CKM_AES_ECB, CKA_ENCRYPT, key, &my_param));
if (!ctx) {
DVLOG(1) << "PK11_CreateContextBySymKey failed";
return SECFailure;
}
int output_len;
- if (PK11_CipherOp(ctx.get(), ghash_key, &output_len, sizeof(ghash_key),
- ghash_key, sizeof(ghash_key)) != SECSuccess) {
+ if (PK11_CipherOp(ctx.get(),
+ ghash_key,
+ &output_len,
+ sizeof(ghash_key),
+ ghash_key,
+ sizeof(ghash_key)) != SECSuccess) {
DVLOG(1) << "PK11_CipherOp failed";
return SECFailure;
}
@@ -148,8 +150,8 @@ SECStatus My_Encrypt(PK11SymKey* key,
my_param.data = reinterpret_cast<unsigned char*>(&ctr_params);
my_param.len = sizeof(ctr_params);
- ctx.reset(PK11_CreateContextBySymKey(CKM_AES_CTR, CKA_ENCRYPT, key,
- &my_param));
+ ctx.reset(
+ PK11_CreateContextBySymKey(CKM_AES_CTR, CKA_ENCRYPT, key, &my_param));
if (!ctx) {
DVLOG(1) << "PK11_CreateContextBySymKey failed";
return SECFailure;
@@ -157,8 +159,12 @@ SECStatus My_Encrypt(PK11SymKey* key,
// Step 6. Calculate the encryption mask of GCTR_K(J0, ...).
unsigned char tag_mask[16] = {0};
- if (PK11_CipherOp(ctx.get(), tag_mask, &output_len, sizeof(tag_mask),
- tag_mask, sizeof(tag_mask)) != SECSuccess) {
+ if (PK11_CipherOp(ctx.get(),
+ tag_mask,
+ &output_len,
+ sizeof(tag_mask),
+ tag_mask,
+ sizeof(tag_mask)) != SECSuccess) {
DVLOG(1) << "PK11_CipherOp failed";
return SECFailure;
}
@@ -171,8 +177,12 @@ SECStatus My_Encrypt(PK11SymKey* key,
// The const_cast for |data| can be removed if system NSS libraries are
// NSS 3.14.1 or later (NSS bug
// https://bugzilla.mozilla.org/show_bug.cgi?id=808218).
- if (PK11_CipherOp(ctx.get(), out, &output_len, max_len,
- const_cast<unsigned char*>(data), data_len) != SECSuccess) {
+ if (PK11_CipherOp(ctx.get(),
+ out,
+ &output_len,
+ max_len,
+ const_cast<unsigned char*>(data),
+ data_len) != SECSuccess) {
DVLOG(1) << "PK11_CipherOp failed";
return SECFailure;
}
@@ -207,7 +217,10 @@ SECStatus My_Encrypt(PK11SymKey* key,
} // namespace
Aes128Gcm12Encrypter::Aes128Gcm12Encrypter()
- : AeadBaseEncrypter(CKM_AES_GCM, My_Encrypt, kKeySize, kAuthTagSize,
+ : AeadBaseEncrypter(CKM_AES_GCM,
+ My_Encrypt,
+ kKeySize,
+ kAuthTagSize,
kNoncePrefixSize) {
COMPILE_ASSERT(kKeySize <= kMaxKeySize, key_size_too_big);
COMPILE_ASSERT(kNoncePrefixSize <= kMaxNoncePrefixSize,
@@ -215,7 +228,8 @@ Aes128Gcm12Encrypter::Aes128Gcm12Encrypter()
ignore_result(g_gcm_support_checker.Get());
}
-Aes128Gcm12Encrypter::~Aes128Gcm12Encrypter() {}
+Aes128Gcm12Encrypter::~Aes128Gcm12Encrypter() {
+}
void Aes128Gcm12Encrypter::FillAeadParams(StringPiece nonce,
StringPiece associated_data,
@@ -223,8 +237,7 @@ void Aes128Gcm12Encrypter::FillAeadParams(StringPiece nonce,
AeadParams* aead_params) const {
aead_params->len = sizeof(aead_params->data.gcm_params);
CK_GCM_PARAMS* gcm_params = &aead_params->data.gcm_params;
- gcm_params->pIv =
- reinterpret_cast<CK_BYTE*>(const_cast<char*>(nonce.data()));
+ gcm_params->pIv = reinterpret_cast<CK_BYTE*>(const_cast<char*>(nonce.data()));
gcm_params->ulIvLen = nonce.size();
gcm_params->pAAD =
reinterpret_cast<CK_BYTE*>(const_cast<char*>(associated_data.data()));

Powered by Google App Engine
This is Rietveld 408576698