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 { | |
| 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) |signed_data| matches the hashed |unsigned_data| encrypted with | |
| 25 // the public key in |certificate|. | |
| 26 bool VerifyCredentials(const std::string& certificate, | |
| 27 const std::string& signed_data, | |
| 28 const std::string& unsigned_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 | |
| 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. | |
| 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, | |
| 47 const std::string& encrypted_data, | |
| 48 std::string* decrypted_output); | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateCrypto); | |
|
Ryan Sleevi
2013/08/28 21:52:29
This should be private:
mef
2013/08/29 14:59:09
Done.
| |
| 51 }; | |
| 52 | |
| 53 #endif // CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_C RYPTO_H_ | |
| OLD | NEW |