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

Side by Side Diff: chromeos/login/auth/key_unittest.cc

Issue 515153002: Add new Chrome OS key type: Salted SHA256 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@d_2_367847_add_get_key_data_ex_call
Patch Set: Created 6 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
« no previous file with comments | « chromeos/login/auth/key.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/login/auth/key.h" 5 #include "chromeos/login/auth/key.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace chromeos { 9 namespace chromeos {
10 10
(...skipping 26 matching lines...) Expand all
37 EXPECT_EQ("5b01941771e47fa408380aa675703f4f", key.GetSecret()); 37 EXPECT_EQ("5b01941771e47fa408380aa675703f4f", key.GetSecret());
38 } 38 }
39 39
40 TEST(KeyTest, TransformToSaltedAES2561234) { 40 TEST(KeyTest, TransformToSaltedAES2561234) {
41 Key key(kPassword); 41 Key key(kPassword);
42 key.Transform(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, kSalt); 42 key.Transform(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, kSalt);
43 EXPECT_EQ(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, key.GetKeyType()); 43 EXPECT_EQ(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, key.GetKeyType());
44 EXPECT_EQ("GUkNnvqoULf/cXbZscVUnANmLBB0ovjGZsj1sKzP5BE=", key.GetSecret()); 44 EXPECT_EQ("GUkNnvqoULf/cXbZscVUnANmLBB0ovjGZsj1sKzP5BE=", key.GetSecret());
45 } 45 }
46 46
47 TEST(KeyTest, TransformToSaltedSHA256) {
48 Key key(kPassword);
49 key.Transform(Key::KEY_TYPE_SALTED_SHA256, kSalt);
50 EXPECT_EQ(Key::KEY_TYPE_SALTED_SHA256, key.GetKeyType());
51 EXPECT_EQ("WwGUF3Hkf6QIOAqmdXA/TyScTFDo4d+ow5xfof0zGdo=", key.GetSecret());
52 }
53
54 // The values in the KeyType enum must never change because they are stored as
55 // ints in the user's cryptohome key metadata.
56 TEST(KeyTest, KeyTypeStable) {
57 EXPECT_EQ(0, Key::KEY_TYPE_PASSWORD_PLAIN);
58 EXPECT_EQ(1, Key::KEY_TYPE_SALTED_SHA256_TOP_HALF);
59 EXPECT_EQ(2, Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234);
60 EXPECT_EQ(3, Key::KEY_TYPE_SALTED_SHA256);
61 // The sentinel does not have to remain stable. It should be adjusted whenever
62 // a new key type is added.
63 EXPECT_EQ(4, Key::KEY_TYPE_COUNT);
64 }
65
47 } // namespace chromeos 66 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/login/auth/key.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698