Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Implementation of Crypto support for networking private API. | |
| 6 // Based on chromeos_public//src/platform/shill/shims/crypto_util.cc | |
| 7 | |
| 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_CRYP TO_H_ | |
| 9 #define CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_CRYP TO_H_ | |
| 10 | |
| 11 #include <string> | |
| 12 #include "base/basictypes.h" | |
| 13 | |
| 14 class NetworkingPrivateCrypto { | |
|
Greg Spencer (Chromium)
2013/08/30 18:38:17
Document what the function of this class is, and w
mef
2013/08/30 20:07:17
Done.
| |
| 15 public: | |
| 16 NetworkingPrivateCrypto(); | |
| 17 ~NetworkingPrivateCrypto(); | |
| 18 | |
| 19 // Verify that credentials described by |certificate| and |signed_data| are | |
| 20 // valid. | |
| 21 // | |
| 22 // 1) The MAC address listed in the certificate matches |connected_mac|. | |
| 23 // 2) The certificate is a valid PEM encoded certificate signed by trusted CA. | |
| 24 // 3) |signature| is a valid signature for |data|, using the public key in | |
| 25 // |certificate| | |
| 26 bool VerifyCredentials(const std::string& certificate, | |
| 27 const std::string& signature, | |
| 28 const std::string& data, | |
| 29 const std::string& connected_mac); | |
| 30 | |
| 31 // Encrypt |data| with |public_key|. |public_key| is the raw bytes of a key | |
| 32 // in RSAPublicKey format. |data| is some string of bytes smaller than the | |
|
Ryan Sleevi
2013/08/30 18:40:26
comment nit: |public_key| is a DER-encoded RSAPubl
mef
2013/08/30 20:07:17
Done.
| |
| 33 // maximum length permissable for encryption with a key of |public_key| size. | |
| 34 // | |
| 35 // Returns the encrypted result in |encrypted_output| and returns true on | |
| 36 // success. | |
|
Ryan Sleevi
2013/08/30 18:40:26
comment nit: You can avoid the double returns (whi
mef
2013/08/30 20:07:17
Done.
| |
| 37 bool EncryptByteString(const std::string& public_key, | |
| 38 const std::string& data, | |
| 39 std::string* encrypted_output); | |
| 40 | |
| 41 // Decrypt |encrypted_data| with |private_key_pem|. |private_key_pem| is the | |
| 42 // PKCS8 PEM-encoded private key. |encrypted_data| is data encrypted with | |
| 43 // EncryptByteString. | |
| 44 // Returns the decrypted result in |decrypted_output| and returns true on | |
| 45 // success. | |
| 46 bool DecryptByteString(const std::string& private_key_pem, | |
|
Ryan Sleevi
2013/08/30 18:40:26
If this is only used for unittesting, make it priv
mef
2013/08/30 20:07:17
Done.
| |
| 47 const std::string& encrypted_data, | |
| 48 std::string* decrypted_output); | |
| 49 | |
| 50 private: | |
| 51 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateCrypto); | |
| 52 }; | |
| 53 | |
| 54 #endif // CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_C RYPTO_H_ | |
| OLD | NEW |