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

Unified Diff: crypto/signature_creator_unittest.cc

Issue 1539353003: Switch to standard integer types in crypto/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crypto/signature_creator_openssl.cc ('k') | crypto/signature_verifier.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/signature_creator_unittest.cc
diff --git a/crypto/signature_creator_unittest.cc b/crypto/signature_creator_unittest.cc
index 694becdcb4475effc0e4c35dceebe0c6db2a14d5..af1a04212675a4a1f59cc1de88403ff8823b286c 100644
--- a/crypto/signature_creator_unittest.cc
+++ b/crypto/signature_creator_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <stdint.h>
+
#include <vector>
#include "base/memory/scoped_ptr.h"
@@ -15,17 +17,14 @@
namespace {
// This is the algorithm ID for SHA-1 with RSA encryption.
-const uint8 kSHA1WithRSAAlgorithmID[] = {
- 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
- 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00
-};
+const uint8_t kSHA1WithRSAAlgorithmID[] = {0x30, 0x0d, 0x06, 0x09, 0x2a,
+ 0x86, 0x48, 0x86, 0xf7, 0x0d,
+ 0x01, 0x01, 0x05, 0x05, 0x00};
// This is the algorithm ID for SHA-1 with RSA encryption.
-const uint8 kSHA256WithRSAAlgorithmID[] = {
- 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
- 0xf7, 0x0d, 0x01, 0x01, 0x0B, 0x05, 0x00
-};
-
+const uint8_t kSHA256WithRSAAlgorithmID[] = {0x30, 0x0d, 0x06, 0x09, 0x2a,
+ 0x86, 0x48, 0x86, 0xf7, 0x0d,
+ 0x01, 0x01, 0x0B, 0x05, 0x00};
}
TEST(SignatureCreatorTest, BasicTest) {
@@ -34,7 +33,7 @@ TEST(SignatureCreatorTest, BasicTest) {
crypto::RSAPrivateKey::Create(1024));
ASSERT_TRUE(key_original.get());
- std::vector<uint8> key_info;
+ std::vector<uint8_t> key_info;
key_original->ExportPrivateKey(&key_info);
scoped_ptr<crypto::RSAPrivateKey> key(
crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_info));
@@ -46,13 +45,13 @@ TEST(SignatureCreatorTest, BasicTest) {
ASSERT_TRUE(signer.get());
std::string data("Hello, World!");
- ASSERT_TRUE(signer->Update(reinterpret_cast<const uint8*>(data.c_str()),
+ ASSERT_TRUE(signer->Update(reinterpret_cast<const uint8_t*>(data.c_str()),
data.size()));
- std::vector<uint8> signature;
+ std::vector<uint8_t> signature;
ASSERT_TRUE(signer->Final(&signature));
- std::vector<uint8> public_key_info;
+ std::vector<uint8_t> public_key_info;
ASSERT_TRUE(key_original->ExportPublicKey(&public_key_info));
crypto::SignatureVerifier verifier;
@@ -61,7 +60,7 @@ TEST(SignatureCreatorTest, BasicTest) {
&signature.front(), signature.size(),
&public_key_info.front(), public_key_info.size()));
- verifier.VerifyUpdate(reinterpret_cast<const uint8*>(data.c_str()),
+ verifier.VerifyUpdate(reinterpret_cast<const uint8_t*>(data.c_str()),
data.size());
ASSERT_TRUE(verifier.VerifyFinal());
}
@@ -72,7 +71,7 @@ TEST(SignatureCreatorTest, SignDigestTest) {
crypto::RSAPrivateKey::Create(1024));
ASSERT_TRUE(key_original.get());
- std::vector<uint8> key_info;
+ std::vector<uint8_t> key_info;
key_original->ExportPrivateKey(&key_info);
scoped_ptr<crypto::RSAPrivateKey> key(
crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_info));
@@ -81,15 +80,12 @@ TEST(SignatureCreatorTest, SignDigestTest) {
std::string data("Hello, World!");
std::string sha1 = base::SHA1HashString(data);
// Sign sha1 of the input data.
- std::vector<uint8> signature;
+ std::vector<uint8_t> signature;
ASSERT_TRUE(crypto::SignatureCreator::Sign(
- key.get(),
- crypto::SignatureCreator::SHA1,
- reinterpret_cast<const uint8*>(sha1.c_str()),
- sha1.size(),
- &signature));
+ key.get(), crypto::SignatureCreator::SHA1,
+ reinterpret_cast<const uint8_t*>(sha1.c_str()), sha1.size(), &signature));
- std::vector<uint8> public_key_info;
+ std::vector<uint8_t> public_key_info;
ASSERT_TRUE(key_original->ExportPublicKey(&public_key_info));
// Verify the input data.
@@ -99,7 +95,7 @@ TEST(SignatureCreatorTest, SignDigestTest) {
&signature.front(), signature.size(),
&public_key_info.front(), public_key_info.size()));
- verifier.VerifyUpdate(reinterpret_cast<const uint8*>(data.c_str()),
+ verifier.VerifyUpdate(reinterpret_cast<const uint8_t*>(data.c_str()),
data.size());
ASSERT_TRUE(verifier.VerifyFinal());
}
@@ -110,7 +106,7 @@ TEST(SignatureCreatorTest, SignSHA256DigestTest) {
crypto::RSAPrivateKey::Create(1024));
ASSERT_TRUE(key_original.get());
- std::vector<uint8> key_info;
+ std::vector<uint8_t> key_info;
key_original->ExportPrivateKey(&key_info);
scoped_ptr<crypto::RSAPrivateKey> key(
crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_info));
@@ -119,15 +115,13 @@ TEST(SignatureCreatorTest, SignSHA256DigestTest) {
std::string data("Hello, World!");
std::string sha256 = crypto::SHA256HashString(data);
// Sign sha256 of the input data.
- std::vector<uint8> signature;
+ std::vector<uint8_t> signature;
ASSERT_TRUE(crypto::SignatureCreator::Sign(
- key.get(),
- crypto::SignatureCreator::HashAlgorithm::SHA256,
- reinterpret_cast<const uint8*>(sha256.c_str()),
- sha256.size(),
+ key.get(), crypto::SignatureCreator::HashAlgorithm::SHA256,
+ reinterpret_cast<const uint8_t*>(sha256.c_str()), sha256.size(),
&signature));
- std::vector<uint8> public_key_info;
+ std::vector<uint8_t> public_key_info;
ASSERT_TRUE(key_original->ExportPublicKey(&public_key_info));
// Verify the input data.
@@ -137,7 +131,7 @@ TEST(SignatureCreatorTest, SignSHA256DigestTest) {
&signature.front(), signature.size(),
&public_key_info.front(), public_key_info.size()));
- verifier.VerifyUpdate(reinterpret_cast<const uint8*>(data.c_str()),
+ verifier.VerifyUpdate(reinterpret_cast<const uint8_t*>(data.c_str()),
data.size());
ASSERT_TRUE(verifier.VerifyFinal());
}
« no previous file with comments | « crypto/signature_creator_openssl.cc ('k') | crypto/signature_verifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698