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

Unified Diff: net/quic/crypto/quic_decrypter.cc

Issue 1904213002: QUIC: support diversified keys with version 33. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hkdf
Patch Set: Rebase Created 4 years, 8 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
« no previous file with comments | « net/quic/crypto/quic_decrypter.h ('k') | net/quic/p2p/quic_p2p_crypto_config.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/crypto/quic_decrypter.cc
diff --git a/net/quic/crypto/quic_decrypter.cc b/net/quic/crypto/quic_decrypter.cc
index eae1f8fcf6d6f3fcaa5776da6cc01cb19ca869f7..193d1e87eb4a0a44774df4670268d6eb3f47eba4 100644
--- a/net/quic/crypto/quic_decrypter.cc
+++ b/net/quic/crypto/quic_decrypter.cc
@@ -4,11 +4,15 @@
#include "net/quic/crypto/quic_decrypter.h"
+#include "crypto/hkdf.h"
#include "net/quic/crypto/aes_128_gcm_12_decrypter.h"
#include "net/quic/crypto/chacha20_poly1305_rfc7539_decrypter.h"
#include "net/quic/crypto/crypto_protocol.h"
#include "net/quic/crypto/null_decrypter.h"
+using base::StringPiece;
+using std::string;
+
namespace net {
// static
@@ -26,4 +30,20 @@ QuicDecrypter* QuicDecrypter::Create(QuicTag algorithm) {
}
}
+// static
+void QuicDecrypter::DiversifyPreliminaryKey(StringPiece preliminary_key,
+ StringPiece nonce_prefix,
+ DiversificationNonce nonce,
+ size_t key_size,
+ size_t nonce_prefix_size,
+ string* out_key,
+ string* out_nonce_prefix) {
+ crypto::HKDF hkdf(preliminary_key.as_string() + nonce_prefix.as_string(),
+ StringPiece(nonce, kDiversificationNonceSize),
+ "QUIC key diversification", 0, key_size, 0,
+ nonce_prefix_size, 0);
+ *out_key = hkdf.server_write_key().as_string();
+ *out_nonce_prefix = hkdf.server_write_iv().as_string();
+}
+
} // namespace net
« no previous file with comments | « net/quic/crypto/quic_decrypter.h ('k') | net/quic/p2p/quic_p2p_crypto_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698