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

Side by Side Diff: chrome/browser/extensions/api/networking_private/networking_private_crypto.h

Issue 23710003: Added NetworkingPrivateCrypto and its unit test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use VFY_VerifyDataDirect as VFY_VerifyData is deprecated. Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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,
Ryan Sleevi 2013/08/29 21:30:43 naming: "signed_data" and "unsigned_data" should b
mef 2013/08/30 17:07:39 Done.
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 private:
Ryan Sleevi 2013/08/29 21:30:43 style nit: Line break between 48 & 49
mef 2013/08/30 17:07:39 Done.
50 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateCrypto);
51 };
52
53 #endif // CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_C RYPTO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698