52 lines
1.8 KiB
C++
52 lines
1.8 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// Copyright 2016 Google Inc.
|
|
//
|
|
// This software is licensed under the terms defined in the Widevine Master
|
|
// License Agreement. For a copy of this agreement, please contact
|
|
// widevine-licensing@google.com.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "common/sha_util.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
namespace widevine {
|
|
|
|
TEST(ShaUtilTest, Sha1Empty) {
|
|
const uint8_t kExpected[] = {
|
|
0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55,
|
|
0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09,
|
|
};
|
|
EXPECT_EQ(std::string(kExpected, kExpected + sizeof(kExpected)), Sha1_Hash(""));
|
|
}
|
|
|
|
TEST(ShaUtilTest, Sha256Empty) {
|
|
const uint8_t kExpected[] = {
|
|
0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4,
|
|
0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b,
|
|
0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55,
|
|
};
|
|
EXPECT_EQ(std::string(kExpected, kExpected + sizeof(kExpected)), Sha256_Hash(""));
|
|
}
|
|
|
|
TEST(ShaUtilTest, Sha1) {
|
|
const uint8_t kExpected[] = {
|
|
0x5f, 0xfd, 0x3b, 0x85, 0x2c, 0xcd, 0xd4, 0x48, 0x80, 0x9a,
|
|
0xbb, 0x17, 0x2e, 0x19, 0xbb, 0xb9, 0xc0, 0x1a, 0x43, 0xa4,
|
|
};
|
|
EXPECT_EQ(std::string(kExpected, kExpected + sizeof(kExpected)),
|
|
Sha1_Hash("random std::string"));
|
|
}
|
|
|
|
TEST(ShaUtilTest, Sha256) {
|
|
const uint8_t kExpected[] = {
|
|
0xa8, 0x2a, 0xf4, 0xe9, 0x6b, 0x5b, 0x8d, 0x82, 0x5a, 0x69, 0x10,
|
|
0xb9, 0x08, 0xec, 0xcd, 0xc4, 0x40, 0x1a, 0xf1, 0xe6, 0x63, 0xdb,
|
|
0x5e, 0xdf, 0x2d, 0x7d, 0xfb, 0x71, 0x2d, 0xb9, 0x65, 0x29,
|
|
};
|
|
EXPECT_EQ(std::string(kExpected, kExpected + sizeof(kExpected)),
|
|
Sha256_Hash("random std::string"));
|
|
}
|
|
|
|
} // namespace widevine
|