1 // Copyright 2014 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 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h" 5 6 #include "base/values.h" 7 #include "chrome/browser/chromeos/login/auth/key.h" 8 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 9 #include "testing/gtest/include/gtest/gtest.h" 10 11 namespace chromeos { 12 13 class SupervisedUserAuthenticationTest : public testing::Test { 14 protected: 15 SupervisedUserAuthenticationTest(); 16 virtual ~SupervisedUserAuthenticationTest(); 17 18 // testing::Test: 19 virtual void SetUp() OVERRIDE; 20 virtual void TearDown() OVERRIDE; 21 22 DISALLOW_COPY_AND_ASSIGN(SupervisedUserAuthenticationTest); 23 }; 24 25 SupervisedUserAuthenticationTest::SupervisedUserAuthenticationTest() {} 26 27 SupervisedUserAuthenticationTest::~SupervisedUserAuthenticationTest() {} 28 29 void SupervisedUserAuthenticationTest::SetUp() {} 30 31 void SupervisedUserAuthenticationTest::TearDown() {} 32 33 TEST_F(SupervisedUserAuthenticationTest, SignatureGeneration) { 34 std::string password = "password"; 35 int revision = 1; 36 std::string salt = 37 "204cc733ebe526ea9a84885de904eb7a578d86a4c385d252dce275d9d9675c37"; 38 std::string expected_salted_password = 39 "OSL3HZZSfK+mDQTYUh3lXhgAzJNWhYz52ax0Bleny7Q="; 40 std::string signature_key = "p5TR/34XX0R7IMuffH14BiL1vcdSD8EajPzdIg09z9M="; 41 std::string expected_signature = 42 "KOPQmmJcMr9iMkr36N1cX+G9gDdBBu7zutAxNayPMN4="; 43 44 Key key(password); 45 key.Transform(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, salt); 46 ASSERT_EQ(expected_salted_password, key.GetSecret()); 47 std::string signature = SupervisedUserAuthentication::BuildPasswordSignature( 48 key.GetSecret(), revision, signature_key); 49 ASSERT_EQ(expected_signature, signature); 50 } 51 52 } // namespace chromeos 53