summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravi <avi@chromium.org>2015-12-21 13:34:43 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-21 21:35:49 +0000
commitdd373b8b7d7501cf7f3bbfe861f58dce67578a69 (patch)
tree037d2922a3dc5079e1eff59e9a3eb5fe3c605fa0
parent64114156487081d877b793d3a501a8658743141d (diff)
downloadchromium_src-dd373b8b7d7501cf7f3bbfe861f58dce67578a69.zip
chromium_src-dd373b8b7d7501cf7f3bbfe861f58dce67578a69.tar.gz
chromium_src-dd373b8b7d7501cf7f3bbfe861f58dce67578a69.tar.bz2
Switch to standard integer types in crypto/.
BUG=138542 TBR=rsleevi@chromium.org NOPRESUBMIT=true Review URL: https://codereview.chromium.org/1539353003 Cr-Commit-Position: refs/heads/master@{#366460}
-rw-r--r--crypto/aead_openssl.cc28
-rw-r--r--crypto/aead_openssl.h2
-rw-r--r--crypto/apple_keychain.h3
-rw-r--r--crypto/capi_util.cc4
-rw-r--r--crypto/capi_util.h1
-rw-r--r--crypto/cssm_init.cc3
-rw-r--r--crypto/cssm_init.h2
-rw-r--r--crypto/curve25519_nss.cc2
-rw-r--r--crypto/curve25519_openssl.cc1
-rw-r--r--crypto/curve25519_unittest.cc2
-rw-r--r--crypto/ec_private_key.h19
-rw-r--r--crypto/ec_private_key_nss.cc23
-rw-r--r--crypto/ec_private_key_openssl.cc27
-rw-r--r--crypto/ec_private_key_unittest.cc69
-rw-r--r--crypto/ec_signature_creator.h11
-rw-r--r--crypto/ec_signature_creator_impl.h11
-rw-r--r--crypto/ec_signature_creator_nss.cc16
-rw-r--r--crypto/ec_signature_creator_openssl.cc13
-rw-r--r--crypto/ec_signature_creator_unittest.cc23
-rw-r--r--crypto/encryptor.cc17
-rw-r--r--crypto/encryptor.h10
-rw-r--r--crypto/encryptor_nss.cc19
-rw-r--r--crypto/encryptor_openssl.cc23
-rw-r--r--crypto/encryptor_unittest.cc3
-rw-r--r--crypto/ghash.cc33
-rw-r--r--crypto/ghash.h18
-rw-r--r--crypto/ghash_unittest.cc61
-rw-r--r--crypto/hkdf.cc7
-rw-r--r--crypto/hkdf.h6
-rw-r--r--crypto/hkdf_unittest.cc6
-rw-r--r--crypto/hmac.cc2
-rw-r--r--crypto/hmac.h4
-rw-r--r--crypto/hmac_nss.cc1
-rw-r--r--crypto/hmac_openssl.cc1
-rw-r--r--crypto/hmac_unittest.cc3
-rw-r--r--crypto/hmac_win.cc1
-rw-r--r--crypto/mac_security_services_lock.cc1
-rw-r--r--crypto/mock_apple_keychain.cc1
-rw-r--r--crypto/mock_apple_keychain.h1
-rw-r--r--crypto/mock_apple_keychain_mac.cc3
-rw-r--r--crypto/nss_key_util.cc1
-rw-r--r--crypto/nss_key_util_unittest.cc1
-rw-r--r--crypto/nss_util.h12
-rw-r--r--crypto/nss_util_internal.h1
-rw-r--r--crypto/openssl_util.cc3
-rw-r--r--crypto/openssl_util.h4
-rw-r--r--crypto/p224.cc114
-rw-r--r--crypto/p224.h12
-rw-r--r--crypto/p224_spake.cc8
-rw-r--r--crypto/p224_spake.h25
-rw-r--r--crypto/p224_spake_unittest.cc5
-rw-r--r--crypto/p224_unittest.cc25
-rw-r--r--crypto/random.cc2
-rw-r--r--crypto/random_unittest.cc2
-rw-r--r--crypto/rsa_private_key.cc122
-rw-r--r--crypto/rsa_private_key.h119
-rw-r--r--crypto/rsa_private_key_nss.cc11
-rw-r--r--crypto/rsa_private_key_openssl.cc11
-rw-r--r--crypto/rsa_private_key_unittest.cc505
-rw-r--r--crypto/scoped_capi_types.h1
-rw-r--r--crypto/scoped_openssl_types.h1
-rw-r--r--crypto/secure_hash.h4
-rw-r--r--crypto/secure_hash_default.cc2
-rw-r--r--crypto/secure_hash_openssl.cc2
-rw-r--r--crypto/secure_hash_unittest.cc10
-rw-r--r--crypto/secure_util.cc2
-rw-r--r--crypto/sha2.cc2
-rw-r--r--crypto/sha2.h2
-rw-r--r--crypto/sha2_unittest.cc18
-rw-r--r--crypto/signature_creator.h12
-rw-r--r--crypto/signature_creator_nss.cc9
-rw-r--r--crypto/signature_creator_openssl.cc10
-rw-r--r--crypto/signature_creator_unittest.cc56
-rw-r--r--crypto/signature_verifier.h31
-rw-r--r--crypto/signature_verifier_nss.cc21
-rw-r--r--crypto/signature_verifier_openssl.cc17
-rw-r--r--crypto/signature_verifier_unittest.cc360
-rw-r--r--crypto/symmetric_key.h5
-rw-r--r--crypto/symmetric_key_nss.cc2
-rw-r--r--crypto/symmetric_key_openssl.cc15
-rw-r--r--crypto/symmetric_key_win.cc9
-rw-r--r--crypto/third_party/nss/secsign.cc6
82 files changed, 1051 insertions, 1010 deletions
diff --git a/crypto/aead_openssl.cc b/crypto/aead_openssl.cc
index 54795b8..7249421 100644
--- a/crypto/aead_openssl.cc
+++ b/crypto/aead_openssl.cc
@@ -8,9 +8,10 @@
#include <openssl/aes.h>
#include <openssl/evp.h>
+#include <stddef.h>
+#include <stdint.h>
#include <string>
-#include "base/basictypes.h"
#include "base/strings/string_util.h"
#include "crypto/openssl_util.h"
@@ -43,7 +44,7 @@ bool Aead::Seal(const base::StringPiece& plaintext,
EVP_AEAD_CTX ctx;
if (!EVP_AEAD_CTX_init(&ctx, aead_,
- reinterpret_cast<const uint8*>(key_->data()),
+ reinterpret_cast<const uint8_t*>(key_->data()),
key_->size(), EVP_AEAD_DEFAULT_TAG_LENGTH, nullptr)) {
return false;
}
@@ -52,14 +53,14 @@ bool Aead::Seal(const base::StringPiece& plaintext,
const size_t max_output_length =
EVP_AEAD_max_overhead(aead_) + plaintext.size();
size_t output_length;
- uint8* out_ptr =
- reinterpret_cast<uint8*>(base::WriteInto(&result, max_output_length + 1));
+ uint8_t* out_ptr = reinterpret_cast<uint8_t*>(
+ base::WriteInto(&result, max_output_length + 1));
if (!EVP_AEAD_CTX_seal(
&ctx, out_ptr, &output_length, max_output_length,
- reinterpret_cast<const uint8*>(nonce.data()), nonce.size(),
- reinterpret_cast<const uint8*>(plaintext.data()), plaintext.size(),
- reinterpret_cast<const uint8*>(additional_data.data()),
+ reinterpret_cast<const uint8_t*>(nonce.data()), nonce.size(),
+ reinterpret_cast<const uint8_t*>(plaintext.data()), plaintext.size(),
+ reinterpret_cast<const uint8_t*>(additional_data.data()),
additional_data.size())) {
EVP_AEAD_CTX_cleanup(&ctx);
return false;
@@ -82,7 +83,7 @@ bool Aead::Open(const base::StringPiece& ciphertext,
EVP_AEAD_CTX ctx;
if (!EVP_AEAD_CTX_init(&ctx, aead_,
- reinterpret_cast<const uint8*>(key_->data()),
+ reinterpret_cast<const uint8_t*>(key_->data()),
key_->size(), EVP_AEAD_DEFAULT_TAG_LENGTH, nullptr)) {
return false;
}
@@ -90,14 +91,15 @@ bool Aead::Open(const base::StringPiece& ciphertext,
std::string result;
const size_t max_output_length = ciphertext.size();
size_t output_length;
- uint8* out_ptr =
- reinterpret_cast<uint8*>(base::WriteInto(&result, max_output_length + 1));
+ uint8_t* out_ptr = reinterpret_cast<uint8_t*>(
+ base::WriteInto(&result, max_output_length + 1));
if (!EVP_AEAD_CTX_open(
&ctx, out_ptr, &output_length, max_output_length,
- reinterpret_cast<const uint8*>(nonce.data()), nonce.size(),
- reinterpret_cast<const uint8*>(ciphertext.data()), ciphertext.size(),
- reinterpret_cast<const uint8*>(additional_data.data()),
+ reinterpret_cast<const uint8_t*>(nonce.data()), nonce.size(),
+ reinterpret_cast<const uint8_t*>(ciphertext.data()),
+ ciphertext.size(),
+ reinterpret_cast<const uint8_t*>(additional_data.data()),
additional_data.size())) {
EVP_AEAD_CTX_cleanup(&ctx);
return false;
diff --git a/crypto/aead_openssl.h b/crypto/aead_openssl.h
index 773cce1..3ba6041 100644
--- a/crypto/aead_openssl.h
+++ b/crypto/aead_openssl.h
@@ -5,6 +5,8 @@
#ifndef CRYPTO_AEAD_H_
#define CRYPTO_AEAD_H_
+#include <stddef.h>
+
#include "base/strings/string_piece.h"
#include "crypto/crypto_export.h"
diff --git a/crypto/apple_keychain.h b/crypto/apple_keychain.h
index 840ccee8..1ea2473 100644
--- a/crypto/apple_keychain.h
+++ b/crypto/apple_keychain.h
@@ -7,7 +7,8 @@
#include <Security/Security.h>
-#include "base/basictypes.h"
+#include "base/macros.h"
+#include "build/build_config.h"
#include "crypto/crypto_export.h"
#if defined (OS_IOS)
diff --git a/crypto/capi_util.cc b/crypto/capi_util.cc
index 1a3e139..7adfeb8 100644
--- a/crypto/capi_util.cc
+++ b/crypto/capi_util.cc
@@ -4,7 +4,9 @@
#include "crypto/capi_util.h"
-#include "base/basictypes.h"
+#include <stddef.h>
+
+#include "base/macros.h"
#include "base/memory/singleton.h"
#include "base/synchronization/lock.h"
diff --git a/crypto/capi_util.h b/crypto/capi_util.h
index 9d43293..6941033 100644
--- a/crypto/capi_util.h
+++ b/crypto/capi_util.h
@@ -6,6 +6,7 @@
#define CRYPTO_CAPI_UTIL_H_
#include <windows.h>
+#include <stddef.h>
#include "crypto/crypto_export.h"
#include "crypto/wincrypt_shim.h"
diff --git a/crypto/cssm_init.cc b/crypto/cssm_init.cc
index 495e71b..6fa585a 100644
--- a/crypto/cssm_init.cc
+++ b/crypto/cssm_init.cc
@@ -5,6 +5,7 @@
#include "crypto/cssm_init.h"
#include <Security/SecBase.h>
+#include <stdint.h>
#include "base/logging.h"
#include "base/mac/scoped_cftyperef.h"
@@ -32,7 +33,7 @@ void* CSSMRealloc(void* ptr, CSSM_SIZE size, void* alloc_ref) {
return realloc(ptr, size);
}
-void* CSSMCalloc(uint32 num, CSSM_SIZE size, void* alloc_ref) {
+void* CSSMCalloc(uint32_t num, CSSM_SIZE size, void* alloc_ref) {
return calloc(num, size);
}
diff --git a/crypto/cssm_init.h b/crypto/cssm_init.h
index e711099..3eece1b 100644
--- a/crypto/cssm_init.h
+++ b/crypto/cssm_init.h
@@ -7,7 +7,7 @@
#include <Security/cssm.h>
-#include "base/basictypes.h"
+#include "base/macros.h"
#include "crypto/crypto_export.h"
namespace crypto {
diff --git a/crypto/curve25519_nss.cc b/crypto/curve25519_nss.cc
index 746356f..88bf94c 100644
--- a/crypto/curve25519_nss.cc
+++ b/crypto/curve25519_nss.cc
@@ -4,6 +4,8 @@
#include "crypto/curve25519.h"
+#include <stdint.h>
+
#include "crypto/secure_util.h"
// Curve25519 is specified in terms of byte strings, not numbers, so all
diff --git a/crypto/curve25519_openssl.cc b/crypto/curve25519_openssl.cc
index 067e19c..06c2f01 100644
--- a/crypto/curve25519_openssl.cc
+++ b/crypto/curve25519_openssl.cc
@@ -5,6 +5,7 @@
#include "crypto/curve25519.h"
#include <openssl/curve25519.h>
+#include <stdint.h>
namespace crypto {
diff --git a/crypto/curve25519_unittest.cc b/crypto/curve25519_unittest.cc
index 48144ba..15a9981 100644
--- a/crypto/curve25519_unittest.cc
+++ b/crypto/curve25519_unittest.cc
@@ -4,6 +4,8 @@
#include "crypto/curve25519.h"
+#include <stdint.h>
+
#include <string>
#include "crypto/random.h"
diff --git a/crypto/ec_private_key.h b/crypto/ec_private_key.h
index a3ba49d..9a8a02a 100644
--- a/crypto/ec_private_key.h
+++ b/crypto/ec_private_key.h
@@ -5,10 +5,13 @@
#ifndef CRYPTO_EC_PRIVATE_KEY_H_
#define CRYPTO_EC_PRIVATE_KEY_H_
+#include <stddef.h>
+#include <stdint.h>
+
#include <string>
#include <vector>
-#include "base/basictypes.h"
+#include "base/macros.h"
#include "build/build_config.h"
#include "crypto/crypto_export.h"
@@ -45,8 +48,8 @@ class CRYPTO_EXPORT ECPrivateKey {
// Returns NULL if initialization fails.
static ECPrivateKey* CreateFromEncryptedPrivateKeyInfo(
const std::string& password,
- const std::vector<uint8>& encrypted_private_key_info,
- const std::vector<uint8>& subject_public_key_info);
+ const std::vector<uint8_t>& encrypted_private_key_info,
+ const std::vector<uint8_t>& subject_public_key_info);
#if !defined(USE_OPENSSL)
// Imports the key pair into |slot| and returns in |public_key| and |key|.
@@ -56,7 +59,7 @@ class CRYPTO_EXPORT ECPrivateKey {
static bool ImportFromEncryptedPrivateKeyInfo(
PK11SlotInfo* slot,
const std::string& password,
- const uint8* encrypted_private_key_info,
+ const uint8_t* encrypted_private_key_info,
size_t encrypted_private_key_info_len,
CERTSubjectPublicKeyInfo* decoded_spki,
bool permanent,
@@ -82,18 +85,18 @@ class CRYPTO_EXPORT ECPrivateKey {
// of 1000 iterations, on modern systems a larger value may be preferrable.
bool ExportEncryptedPrivateKey(const std::string& password,
int iterations,
- std::vector<uint8>* output);
+ std::vector<uint8_t>* output);
// Exports the public key to an X.509 SubjectPublicKeyInfo block.
- bool ExportPublicKey(std::vector<uint8>* output);
+ bool ExportPublicKey(std::vector<uint8_t>* output);
// Exports the public key as an EC point in the uncompressed point format.
bool ExportRawPublicKey(std::string* output);
// Exports private key data for testing. The format of data stored into output
// doesn't matter other than that it is consistent for the same key.
- bool ExportValue(std::vector<uint8>* output);
- bool ExportECParams(std::vector<uint8>* output);
+ bool ExportValue(std::vector<uint8_t>* output);
+ bool ExportECParams(std::vector<uint8_t>* output);
private:
// Constructor is private. Use one of the Create*() methods above instead.
diff --git a/crypto/ec_private_key_nss.cc b/crypto/ec_private_key_nss.cc
index 5f8a4e6..b65de95 100644
--- a/crypto/ec_private_key_nss.cc
+++ b/crypto/ec_private_key_nss.cc
@@ -14,6 +14,8 @@ extern "C" {
#include <keyhi.h>
#include <pk11pub.h>
#include <secmod.h>
+#include <stddef.h>
+#include <stdint.h>
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -27,7 +29,7 @@ namespace {
// Copied from rsa_private_key_nss.cc.
static bool ReadAttribute(SECKEYPrivateKey* key,
CK_ATTRIBUTE_TYPE type,
- std::vector<uint8>* output) {
+ std::vector<uint8_t>* output) {
SECItem item;
SECStatus rv;
rv = PK11_ReadRawAttribute(PK11_TypePrivKey, key, type, &item);
@@ -102,8 +104,8 @@ ECPrivateKey* ECPrivateKey::Create() {
// static
ECPrivateKey* ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
const std::string& password,
- const std::vector<uint8>& encrypted_private_key_info,
- const std::vector<uint8>& subject_public_key_info) {
+ const std::vector<uint8_t>& encrypted_private_key_info,
+ const std::vector<uint8_t>& subject_public_key_info) {
EnsureNSSInit();
ScopedPK11Slot slot(PK11_GetInternalSlot());
@@ -149,7 +151,7 @@ ECPrivateKey* ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
bool ECPrivateKey::ImportFromEncryptedPrivateKeyInfo(
PK11SlotInfo* slot,
const std::string& password,
- const uint8* encrypted_private_key_info,
+ const uint8_t* encrypted_private_key_info,
size_t encrypted_private_key_info_len,
CERTSubjectPublicKeyInfo* decoded_spki,
bool permanent,
@@ -237,10 +239,9 @@ ECPrivateKey* ECPrivateKey::Copy() const {
return copy.release();
}
-bool ECPrivateKey::ExportEncryptedPrivateKey(
- const std::string& password,
- int iterations,
- std::vector<uint8>* output) {
+bool ECPrivateKey::ExportEncryptedPrivateKey(const std::string& password,
+ int iterations,
+ std::vector<uint8_t>* output) {
// We export as an EncryptedPrivateKeyInfo bundle instead of a plain PKCS #8
// PrivateKeyInfo because PK11_ImportDERPrivateKeyInfoAndReturnKey doesn't
// support EC keys.
@@ -282,7 +283,7 @@ bool ECPrivateKey::ExportEncryptedPrivateKey(
return true;
}
-bool ECPrivateKey::ExportPublicKey(std::vector<uint8>* output) {
+bool ECPrivateKey::ExportPublicKey(std::vector<uint8_t>* output) {
ScopedSECItem der_pubkey(
SECKEY_EncodeDERSubjectPublicKeyInfo(public_key_));
if (!der_pubkey.get()) {
@@ -310,11 +311,11 @@ bool ECPrivateKey::ExportRawPublicKey(std::string* output) {
return true;
}
-bool ECPrivateKey::ExportValue(std::vector<uint8>* output) {
+bool ECPrivateKey::ExportValue(std::vector<uint8_t>* output) {
return ReadAttribute(key_, CKA_VALUE, output);
}
-bool ECPrivateKey::ExportECParams(std::vector<uint8>* output) {
+bool ECPrivateKey::ExportECParams(std::vector<uint8_t>* output) {
return ReadAttribute(key_, CKA_EC_PARAMS, output);
}
diff --git a/crypto/ec_private_key_openssl.cc b/crypto/ec_private_key_openssl.cc
index 9836fa6..d896203 100644
--- a/crypto/ec_private_key_openssl.cc
+++ b/crypto/ec_private_key_openssl.cc
@@ -8,6 +8,8 @@
#include <openssl/evp.h>
#include <openssl/pkcs12.h>
#include <openssl/x509.h>
+#include <stddef.h>
+#include <stdint.h>
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -32,7 +34,7 @@ using ScopedX509_SIG = ScopedOpenSSL<X509_SIG, X509_SIG_free>;
// Helper to export |key| into |output| via the specified ExportBioFunction.
bool ExportKeyWithBio(const void* key,
ExportBioFunction export_fn,
- std::vector<uint8>* output) {
+ std::vector<uint8_t>* output) {
if (!key)
return false;
@@ -62,7 +64,7 @@ typedef int (*ExportDataFunction)(const void* key, unsigned char** data);
// Helper to export |key| into |output| via the specified export function.
bool ExportKey(const void* key,
ExportDataFunction export_fn,
- std::vector<uint8>* output) {
+ std::vector<uint8_t>* output) {
if (!key)
return false;
@@ -112,8 +114,8 @@ ECPrivateKey* ECPrivateKey::Create() {
// static
ECPrivateKey* ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
const std::string& password,
- const std::vector<uint8>& encrypted_private_key_info,
- const std::vector<uint8>& subject_public_key_info) {
+ const std::vector<uint8_t>& encrypted_private_key_info,
+ const std::vector<uint8_t>& subject_public_key_info) {
// NOTE: The |subject_public_key_info| can be ignored here, it is only
// useful for the NSS implementation (which uses the public key's SHA1
// as a lookup key when storing the private one in its store).
@@ -157,10 +159,9 @@ ECPrivateKey* ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
return result.release();
}
-bool ECPrivateKey::ExportEncryptedPrivateKey(
- const std::string& password,
- int iterations,
- std::vector<uint8>* output) {
+bool ECPrivateKey::ExportEncryptedPrivateKey(const std::string& password,
+ int iterations,
+ std::vector<uint8_t>* output) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
// Convert into a PKCS#8 object.
ScopedPKCS8_PRIV_KEY_INFO pkcs8(EVP_PKEY2PKCS8(key_));
@@ -189,7 +190,7 @@ bool ECPrivateKey::ExportEncryptedPrivateKey(
output);
}
-bool ECPrivateKey::ExportPublicKey(std::vector<uint8>* output) {
+bool ECPrivateKey::ExportPublicKey(std::vector<uint8_t>* output) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
return ExportKeyWithBio(
key_, reinterpret_cast<ExportBioFunction>(i2d_PUBKEY_bio), output);
@@ -205,8 +206,8 @@ bool ECPrivateKey::ExportRawPublicKey(std::string* output) {
if (len != kExpectedKeyLength)
return false;
- uint8 buf[kExpectedKeyLength];
- uint8* derp = buf;
+ uint8_t buf[kExpectedKeyLength];
+ uint8_t* derp = buf;
len = i2d_PublicKey(key_, &derp);
if (len != kExpectedKeyLength)
return false;
@@ -215,7 +216,7 @@ bool ECPrivateKey::ExportRawPublicKey(std::string* output) {
return true;
}
-bool ECPrivateKey::ExportValue(std::vector<uint8>* output) {
+bool ECPrivateKey::ExportValue(std::vector<uint8_t>* output) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
ScopedEC_KEY ec_key(EVP_PKEY_get1_EC_KEY(key_));
return ExportKey(ec_key.get(),
@@ -223,7 +224,7 @@ bool ECPrivateKey::ExportValue(std::vector<uint8>* output) {
output);
}
-bool ECPrivateKey::ExportECParams(std::vector<uint8>* output) {
+bool ECPrivateKey::ExportECParams(std::vector<uint8_t>* output) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
ScopedEC_KEY ec_key(EVP_PKEY_get1_EC_KEY(key_));
return ExportKey(ec_key.get(),
diff --git a/crypto/ec_private_key_unittest.cc b/crypto/ec_private_key_unittest.cc
index cfd08f2..57af82e 100644
--- a/crypto/ec_private_key_unittest.cc
+++ b/crypto/ec_private_key_unittest.cc
@@ -4,6 +4,8 @@
#include "crypto/ec_private_key.h"
+#include <stdint.h>
+
#include <vector>
#include "base/macros.h"
@@ -22,19 +24,19 @@ TEST(ECPrivateKeyUnitTest, InitRandomTest) {
ASSERT_TRUE(keypair1.get());
ASSERT_TRUE(keypair2.get());
- std::vector<uint8> key1value;
- std::vector<uint8> key2value;
- std::vector<uint8> key1params;
- std::vector<uint8> key2params;
+ std::vector<uint8_t> key1value;
+ std::vector<uint8_t> key2value;
+ std::vector<uint8_t> key1params;
+ std::vector<uint8_t> key2params;
EXPECT_TRUE(keypair1->ExportValue(&key1value));
EXPECT_TRUE(keypair2->ExportValue(&key2value));
EXPECT_TRUE(keypair1->ExportECParams(&key1params));
EXPECT_TRUE(keypair2->ExportECParams(&key2params));
- std::vector<uint8> privkey1;
- std::vector<uint8> privkey2;
- std::vector<uint8> pubkey1;
- std::vector<uint8> pubkey2;
+ std::vector<uint8_t> privkey1;
+ std::vector<uint8_t> privkey2;
+ std::vector<uint8_t> pubkey1;
+ std::vector<uint8_t> pubkey2;
std::string raw_pubkey1;
std::string raw_pubkey2;
ASSERT_TRUE(keypair1->ExportEncryptedPrivateKey(password1, 1, &privkey1));
@@ -53,10 +55,10 @@ TEST(ECPrivateKeyUnitTest, InitRandomTest) {
ASSERT_TRUE(keypair3.get());
ASSERT_TRUE(keypair4.get());
- std::vector<uint8> key3value;
- std::vector<uint8> key4value;
- std::vector<uint8> key3params;
- std::vector<uint8> key4params;
+ std::vector<uint8_t> key3value;
+ std::vector<uint8_t> key4value;
+ std::vector<uint8_t> key3params;
+ std::vector<uint8_t> key4params;
EXPECT_TRUE(keypair3->ExportValue(&key3value));
EXPECT_TRUE(keypair4->ExportValue(&key4value));
EXPECT_TRUE(keypair3->ExportECParams(&key3params));
@@ -67,8 +69,8 @@ TEST(ECPrivateKeyUnitTest, InitRandomTest) {
EXPECT_EQ(key1params, key3params);
EXPECT_EQ(key2params, key4params);
- std::vector<uint8> pubkey3;
- std::vector<uint8> pubkey4;
+ std::vector<uint8_t> pubkey3;
+ std::vector<uint8_t> pubkey4;
std::string raw_pubkey3;
std::string raw_pubkey4;
EXPECT_TRUE(keypair3->ExportPublicKey(&pubkey3));
@@ -88,20 +90,20 @@ TEST(ECPrivateKeyUnitTest, Copy) {
ASSERT_TRUE(keypair1.get());
ASSERT_TRUE(keypair2.get());
- std::vector<uint8> key1value;
- std::vector<uint8> key2value;
+ std::vector<uint8_t> key1value;
+ std::vector<uint8_t> key2value;
EXPECT_TRUE(keypair1->ExportValue(&key1value));
EXPECT_TRUE(keypair2->ExportValue(&key2value));
EXPECT_EQ(key1value, key2value);
- std::vector<uint8> key1params;
- std::vector<uint8> key2params;
+ std::vector<uint8_t> key1params;
+ std::vector<uint8_t> key2params;
EXPECT_TRUE(keypair1->ExportECParams(&key1params));
EXPECT_TRUE(keypair2->ExportECParams(&key2params));
EXPECT_EQ(key1params, key2params);
- std::vector<uint8> pubkey1;
- std::vector<uint8> pubkey2;
+ std::vector<uint8_t> pubkey1;
+ std::vector<uint8_t> pubkey2;
EXPECT_TRUE(keypair1->ExportPublicKey(&pubkey1));
EXPECT_TRUE(keypair2->ExportPublicKey(&pubkey2));
EXPECT_EQ(pubkey1, pubkey2);
@@ -121,8 +123,8 @@ TEST(ECPrivateKeyUnitTest, BadPasswordTest) {
crypto::ECPrivateKey::Create());
ASSERT_TRUE(keypair1.get());
- std::vector<uint8> privkey1;
- std::vector<uint8> pubkey1;
+ std::vector<uint8_t> privkey1;
+ std::vector<uint8_t> pubkey1;
ASSERT_TRUE(keypair1->ExportEncryptedPrivateKey(
password1, 1, &privkey1));
ASSERT_TRUE(keypair1->ExportPublicKey(&pubkey1));
@@ -163,10 +165,9 @@ TEST(ECPrivateKeyUnitTest, LoadNSSKeyTest) {
scoped_ptr<crypto::ECPrivateKey> keypair_nss(
crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
- "",
- std::vector<uint8>(nss_key, nss_key + arraysize(nss_key)),
- std::vector<uint8>(nss_pub_key,
- nss_pub_key + arraysize(nss_pub_key))));
+ "", std::vector<uint8_t>(nss_key, nss_key + arraysize(nss_key)),
+ std::vector<uint8_t>(nss_pub_key,
+ nss_pub_key + arraysize(nss_pub_key))));
EXPECT_TRUE(keypair_nss.get());
}
@@ -202,10 +203,10 @@ TEST(ECPrivateKeyUnitTest, LoadOpenSSLKeyTest) {
scoped_ptr<crypto::ECPrivateKey> keypair_openssl(
crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
- "",
- std::vector<uint8>(openssl_key, openssl_key + arraysize(openssl_key)),
- std::vector<uint8>(openssl_pub_key,
- openssl_pub_key + arraysize(openssl_pub_key))));
+ "", std::vector<uint8_t>(openssl_key,
+ openssl_key + arraysize(openssl_key)),
+ std::vector<uint8_t>(openssl_pub_key,
+ openssl_pub_key + arraysize(openssl_pub_key))));
EXPECT_TRUE(keypair_openssl.get());
}
@@ -284,10 +285,10 @@ TEST(ECPrivateKeyUnitTest, LoadOldOpenSSLKeyTest) {
scoped_ptr<crypto::ECPrivateKey> keypair_openssl(
crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
- "",
- std::vector<uint8>(openssl_key, openssl_key + arraysize(openssl_key)),
- std::vector<uint8>(openssl_pub_key,
- openssl_pub_key + arraysize(openssl_pub_key))));
+ "", std::vector<uint8_t>(openssl_key,
+ openssl_key + arraysize(openssl_key)),
+ std::vector<uint8_t>(openssl_pub_key,
+ openssl_pub_key + arraysize(openssl_pub_key))));
EXPECT_TRUE(keypair_openssl.get());
}
diff --git a/crypto/ec_signature_creator.h b/crypto/ec_signature_creator.h
index 16e64f5..47128fe 100644
--- a/crypto/ec_signature_creator.h
+++ b/crypto/ec_signature_creator.h
@@ -5,10 +5,11 @@
#ifndef CRYPTO_EC_SIGNATURE_CREATOR_H_
#define CRYPTO_EC_SIGNATURE_CREATOR_H_
+#include <stdint.h>
+
#include <string>
#include <vector>
-#include "base/basictypes.h"
#include "crypto/crypto_export.h"
namespace crypto {
@@ -48,17 +49,17 @@ class CRYPTO_EXPORT ECSignatureCreator {
// ECDSA-Sig-Value ::= SEQUENCE {
// r INTEGER,
// s INTEGER }
- virtual bool Sign(const uint8* data,
+ virtual bool Sign(const uint8_t* data,
int data_len,
- std::vector<uint8>* signature) = 0;
+ std::vector<uint8_t>* signature) = 0;
// DecodeSignature converts from a DER encoded ECDSA-Sig-Value (as produced
// by Sign) to a `raw' ECDSA signature which consists of a pair of
// big-endian, zero-padded, 256-bit integers, r and s. On success it returns
// true and puts the raw signature into |out_raw_sig|.
// (Only P-256 signatures are supported.)
- virtual bool DecodeSignature(const std::vector<uint8>& signature,
- std::vector<uint8>* out_raw_sig) = 0;
+ virtual bool DecodeSignature(const std::vector<uint8_t>& signature,
+ std::vector<uint8_t>* out_raw_sig) = 0;
};
} // namespace crypto
diff --git a/crypto/ec_signature_creator_impl.h b/crypto/ec_signature_creator_impl.h
index 95e22e8..21614f8 100644
--- a/crypto/ec_signature_creator_impl.h
+++ b/crypto/ec_signature_creator_impl.h
@@ -5,7 +5,10 @@
#ifndef CRYPTO_EC_SIGNATURE_CREATOR_IMPL_H_
#define CRYPTO_EC_SIGNATURE_CREATOR_IMPL_H_
+#include <stdint.h>
+
#include "base/compiler_specific.h"
+#include "base/macros.h"
#include "crypto/ec_signature_creator.h"
namespace crypto {
@@ -15,12 +18,12 @@ class ECSignatureCreatorImpl : public ECSignatureCreator {
explicit ECSignatureCreatorImpl(ECPrivateKey* key);
~ECSignatureCreatorImpl() override;
- bool Sign(const uint8* data,
+ bool Sign(const uint8_t* data,
int data_len,
- std::vector<uint8>* signature) override;
+ std::vector<uint8_t>* signature) override;
- bool DecodeSignature(const std::vector<uint8>& der_sig,
- std::vector<uint8>* out_raw_sig) override;
+ bool DecodeSignature(const std::vector<uint8_t>& der_sig,
+ std::vector<uint8_t>* out_raw_sig) override;
private:
ECPrivateKey* key_;
diff --git a/crypto/ec_signature_creator_nss.cc b/crypto/ec_signature_creator_nss.cc
index 06a0ad5..7c8cc7d 100644
--- a/crypto/ec_signature_creator_nss.cc
+++ b/crypto/ec_signature_creator_nss.cc
@@ -9,6 +9,8 @@
#include <secerr.h>
#include <sechash.h>
#if defined(OS_POSIX)
+#include <stddef.h>
+#include <stdint.h>
#include <unistd.h>
#endif
@@ -32,7 +34,7 @@ SECStatus SignData(SECItem* result,
}
// Hash the input.
- std::vector<uint8> hash_data(HASH_ResultLen(hash_type));
+ std::vector<uint8_t> hash_data(HASH_ResultLen(hash_type));
SECStatus rv = HASH_HashBuf(
hash_type, &hash_data[0], input->data, input->len);
if (rv != SECSuccess)
@@ -42,7 +44,7 @@ SECStatus SignData(SECItem* result,
// Compute signature of hash.
int signature_len = PK11_SignatureLen(key);
- std::vector<uint8> signature_data(signature_len);
+ std::vector<uint8_t> signature_data(signature_len);
SECItem sig = {siBuffer, &signature_data[0],
static_cast<unsigned int>(signature_len)};
rv = PK11_Sign(key, &sig, &hash);
@@ -62,9 +64,9 @@ ECSignatureCreatorImpl::ECSignatureCreatorImpl(ECPrivateKey* key)
ECSignatureCreatorImpl::~ECSignatureCreatorImpl() {}
-bool ECSignatureCreatorImpl::Sign(const uint8* data,
+bool ECSignatureCreatorImpl::Sign(const uint8_t* data,
int data_len,
- std::vector<uint8>* signature) {
+ std::vector<uint8_t>* signature) {
// Data to be signed
SECItem secret;
secret.type = siBuffer;
@@ -92,12 +94,12 @@ bool ECSignatureCreatorImpl::Sign(const uint8* data,
}
bool ECSignatureCreatorImpl::DecodeSignature(
- const std::vector<uint8>& der_sig,
- std::vector<uint8>* out_raw_sig) {
+ const std::vector<uint8_t>& der_sig,
+ std::vector<uint8_t>* out_raw_sig) {
SECItem der_sig_item;
der_sig_item.type = siBuffer;
der_sig_item.len = der_sig.size();
- der_sig_item.data = const_cast<uint8*>(&der_sig[0]);
+ der_sig_item.data = const_cast<uint8_t*>(&der_sig[0]);
size_t signature_len = SECKEY_SignatureLen(key_->public_key());
if (signature_len == 0)
diff --git a/crypto/ec_signature_creator_openssl.cc b/crypto/ec_signature_creator_openssl.cc
index 30343a7..e9c39b7 100644
--- a/crypto/ec_signature_creator_openssl.cc
+++ b/crypto/ec_signature_creator_openssl.cc
@@ -9,6 +9,8 @@
#include <openssl/ecdsa.h>
#include <openssl/evp.h>
#include <openssl/sha.h>
+#include <stddef.h>
+#include <stdint.h>
#include "base/logging.h"
#include "crypto/ec_private_key.h"
@@ -24,9 +26,9 @@ ECSignatureCreatorImpl::ECSignatureCreatorImpl(ECPrivateKey* key)
ECSignatureCreatorImpl::~ECSignatureCreatorImpl() {}
-bool ECSignatureCreatorImpl::Sign(const uint8* data,
+bool ECSignatureCreatorImpl::Sign(const uint8_t* data,
int data_len,
- std::vector<uint8>* signature) {
+ std::vector<uint8_t>* signature) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
ScopedEVP_MD_CTX ctx(EVP_MD_CTX_create());
size_t sig_len = 0;
@@ -48,8 +50,9 @@ bool ECSignatureCreatorImpl::Sign(const uint8* data,
return true;
}
-bool ECSignatureCreatorImpl::DecodeSignature(const std::vector<uint8>& der_sig,
- std::vector<uint8>* out_raw_sig) {
+bool ECSignatureCreatorImpl::DecodeSignature(
+ const std::vector<uint8_t>& der_sig,
+ std::vector<uint8_t>* out_raw_sig) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
// Create ECDSA_SIG object from DER-encoded data.
const unsigned char* der_data = &der_sig.front();
@@ -60,7 +63,7 @@ bool ECSignatureCreatorImpl::DecodeSignature(const std::vector<uint8>& der_sig,
// The result is made of two 32-byte vectors.
const size_t kMaxBytesPerBN = 32;
- std::vector<uint8> result(2 * kMaxBytesPerBN);
+ std::vector<uint8_t> result(2 * kMaxBytesPerBN);
if (!BN_bn2bin_padded(&result[0], kMaxBytesPerBN, ecdsa_sig->r) ||
!BN_bn2bin_padded(&result[kMaxBytesPerBN], kMaxBytesPerBN,
diff --git a/crypto/ec_signature_creator_unittest.cc b/crypto/ec_signature_creator_unittest.cc
index 2a40cfe..36c850a 100644
--- a/crypto/ec_signature_creator_unittest.cc
+++ b/crypto/ec_signature_creator_unittest.cc
@@ -4,6 +4,8 @@
#include "crypto/ec_signature_creator.h"
+#include <stdint.h>
+
#include <string>
#include <vector>
@@ -21,10 +23,10 @@ TEST(ECSignatureCreatorTest, BasicTest) {
crypto::ECPrivateKey::Create());
ASSERT_TRUE(key_original.get());
- std::vector<uint8> key_info;
+ std::vector<uint8_t> key_info;
ASSERT_TRUE(
key_original->ExportEncryptedPrivateKey(std::string(), 1000, &key_info));
- std::vector<uint8> pubkey_info;
+ std::vector<uint8_t> pubkey_info;
ASSERT_TRUE(key_original->ExportPublicKey(&pubkey_info));
scoped_ptr<crypto::ECPrivateKey> key(
@@ -38,12 +40,11 @@ TEST(ECSignatureCreatorTest, BasicTest) {
ASSERT_TRUE(signer.get());
std::string data("Hello, World!");
- std::vector<uint8> signature;
- ASSERT_TRUE(signer->Sign(reinterpret_cast<const uint8*>(data.c_str()),
- data.size(),
- &signature));
+ std::vector<uint8_t> signature;
+ ASSERT_TRUE(signer->Sign(reinterpret_cast<const uint8_t*>(data.c_str()),
+ data.size(), &signature));
- std::vector<uint8> public_key_info;
+ std::vector<uint8_t> public_key_info;
ASSERT_TRUE(key_original->ExportPublicKey(&public_key_info));
// This is the algorithm ID for ECDSA with SHA-256. Parameters are ABSENT.
@@ -58,10 +59,8 @@ TEST(ECSignatureCreatorTest, BasicTest) {
// component, the OID ecdsa-with-SHA224, ecdsa-with-SHA256, ecdsa-with-
// SHA384, or ecdsa-with-SHA512.
// See also RFC 5480, Appendix A.
- const uint8 kECDSAWithSHA256AlgorithmID[] = {
- 0x30, 0x0a,
- 0x06, 0x08,
- 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02,
+ const uint8_t kECDSAWithSHA256AlgorithmID[] = {
+ 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02,
};
crypto::SignatureVerifier verifier;
ASSERT_TRUE(verifier.VerifyInit(
@@ -69,7 +68,7 @@ TEST(ECSignatureCreatorTest, BasicTest) {
&signature[0], 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());
}
diff --git a/crypto/encryptor.cc b/crypto/encryptor.cc
index a673f81..7872774 100644
--- a/crypto/encryptor.cc
+++ b/crypto/encryptor.cc
@@ -4,6 +4,9 @@
#include "crypto/encryptor.h"
+#include <stddef.h>
+#include <stdint.h>
+
#include "base/logging.h"
#include "base/sys_byteorder.h"
@@ -21,8 +24,8 @@ Encryptor::Counter::~Counter() {
}
bool Encryptor::Counter::Increment() {
- uint64 low_num = base::NetToHost64(counter_.components64[1]);
- uint64 new_low_num = low_num + 1;
+ uint64_t low_num = base::NetToHost64(counter_.components64[1]);
+ uint64_t new_low_num = low_num + 1;
counter_.components64[1] = base::HostToNet64(new_low_num);
// If overflow occured then increment the most significant component.
@@ -36,7 +39,7 @@ bool Encryptor::Counter::Increment() {
}
void Encryptor::Counter::Write(void* buf) {
- uint8* buf_ptr = reinterpret_cast<uint8*>(buf);
+ uint8_t* buf_ptr = reinterpret_cast<uint8_t*>(buf);
memcpy(buf_ptr, &counter_, sizeof(counter_));
}
@@ -58,7 +61,7 @@ bool Encryptor::SetCounter(const base::StringPiece& counter) {
}
bool Encryptor::GenerateCounterMask(size_t plaintext_len,
- uint8* mask,
+ uint8_t* mask,
size_t* mask_len) {
DCHECK_EQ(CTR, mode_);
CHECK(mask);
@@ -86,9 +89,9 @@ void Encryptor::MaskMessage(const void* plaintext,
const void* mask,
void* ciphertext) const {
DCHECK_EQ(CTR, mode_);
- const uint8* plaintext_ptr = reinterpret_cast<const uint8*>(plaintext);
- const uint8* mask_ptr = reinterpret_cast<const uint8*>(mask);
- uint8* ciphertext_ptr = reinterpret_cast<uint8*>(ciphertext);
+ const uint8_t* plaintext_ptr = reinterpret_cast<const uint8_t*>(plaintext);
+ const uint8_t* mask_ptr = reinterpret_cast<const uint8_t*>(mask);
+ uint8_t* ciphertext_ptr = reinterpret_cast<uint8_t*>(ciphertext);
for (size_t i = 0; i < plaintext_len; ++i)
ciphertext_ptr[i] = plaintext_ptr[i] ^ mask_ptr[i];
diff --git a/crypto/encryptor.h b/crypto/encryptor.h
index 85ebaeb..e07eb32 100644
--- a/crypto/encryptor.h
+++ b/crypto/encryptor.h
@@ -5,9 +5,11 @@
#ifndef CRYPTO_ENCRYPTOR_H_
#define CRYPTO_ENCRYPTOR_H_
+#include <stddef.h>
+#include <stdint.h>
+
#include <string>
-#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
#include "build/build_config.h"
@@ -47,8 +49,8 @@ class CRYPTO_EXPORT Encryptor {
private:
union {
- uint32 components32[4];
- uint64 components64[2];
+ uint32_t components32[4];
+ uint64_t components64[2];
} counter_;
};
@@ -99,7 +101,7 @@ class CRYPTO_EXPORT Encryptor {
//
// Returns false if this call failed.
bool GenerateCounterMask(size_t plaintext_len,
- uint8* mask,
+ uint8_t* mask,
size_t* mask_len);
// Mask the |plaintext| message using |mask|. The output will be written to
diff --git a/crypto/encryptor_nss.cc b/crypto/encryptor_nss.cc
index ca5d523..eca1377 100644
--- a/crypto/encryptor_nss.cc
+++ b/crypto/encryptor_nss.cc
@@ -5,6 +5,8 @@
#include "crypto/encryptor.h"
#include <cryptohi.h>
+#include <stddef.h>
+#include <stdint.h>
#include <vector>
#include "base/logging.h"
@@ -116,12 +118,12 @@ bool Encryptor::Crypt(PK11Context* context,
CHECK_GT(output_len, input.size());
output->resize(output_len);
- uint8* output_data =
- reinterpret_cast<uint8*>(const_cast<char*>(output->data()));
+ uint8_t* output_data =
+ reinterpret_cast<uint8_t*>(const_cast<char*>(output->data()));
int input_len = input.size();
- uint8* input_data =
- reinterpret_cast<uint8*>(const_cast<char*>(input.data()));
+ uint8_t* input_data =
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input.data()));
int op_len;
SECStatus rv = PK11_CipherOp(context,
@@ -162,8 +164,8 @@ bool Encryptor::CryptCTR(PK11Context* context,
AES_BLOCK_SIZE;
CHECK_GE(output_len, input.size());
output->resize(output_len);
- uint8* output_data =
- reinterpret_cast<uint8*>(const_cast<char*>(output->data()));
+ uint8_t* output_data =
+ reinterpret_cast<uint8_t*>(const_cast<char*>(output->data()));
size_t mask_len;
bool ret = GenerateCounterMask(input.size(), output_data, &mask_len);
@@ -192,9 +194,8 @@ bool Encryptor::CryptCTR(PK11Context* context,
CHECK(!digest_len);
// Use |output_data| to mask |input|.
- MaskMessage(
- reinterpret_cast<uint8*>(const_cast<char*>(input.data())),
- input.length(), output_data, output_data);
+ MaskMessage(reinterpret_cast<uint8_t*>(const_cast<char*>(input.data())),
+ input.length(), output_data, output_data);
output->resize(input.length());
return true;
}
diff --git a/crypto/encryptor_openssl.cc b/crypto/encryptor_openssl.cc
index 4f0e511..238b2e0 100644
--- a/crypto/encryptor_openssl.cc
+++ b/crypto/encryptor_openssl.cc
@@ -6,6 +6,8 @@
#include <openssl/aes.h>
#include <openssl/evp.h>
+#include <stddef.h>
+#include <stdint.h>
#include "base/logging.h"
#include "base/strings/string_util.h"
@@ -103,21 +105,20 @@ bool Encryptor::Crypt(bool do_encrypt,
DCHECK_EQ(EVP_CIPHER_key_length(cipher), key.length());
ScopedCipherCTX ctx;
- if (!EVP_CipherInit_ex(ctx.get(), cipher, NULL,
- reinterpret_cast<const uint8*>(key.data()),
- reinterpret_cast<const uint8*>(iv_.data()),
- do_encrypt))
+ if (!EVP_CipherInit_ex(
+ ctx.get(), cipher, NULL, reinterpret_cast<const uint8_t*>(key.data()),
+ reinterpret_cast<const uint8_t*>(iv_.data()), do_encrypt))
return false;
// When encrypting, add another block size of space to allow for any padding.
const size_t output_size = input.size() + (do_encrypt ? iv_.size() : 0);
CHECK_GT(output_size, 0u);
CHECK_GT(output_size + 1, input.size());
- uint8* out_ptr =
- reinterpret_cast<uint8*>(base::WriteInto(&result, output_size + 1));
+ uint8_t* out_ptr =
+ reinterpret_cast<uint8_t*>(base::WriteInto(&result, output_size + 1));
int out_len;
if (!EVP_CipherUpdate(ctx.get(), out_ptr, &out_len,
- reinterpret_cast<const uint8*>(input.data()),
+ reinterpret_cast<const uint8_t*>(input.data()),
input.length()))
return false;
@@ -144,7 +145,7 @@ bool Encryptor::CryptCTR(bool do_encrypt,
}
AES_KEY aes_key;
- if (AES_set_encrypt_key(reinterpret_cast<const uint8*>(key_->key().data()),
+ if (AES_set_encrypt_key(reinterpret_cast<const uint8_t*>(key_->key().data()),
key_->key().size() * 8, &aes_key) != 0) {
return false;
}
@@ -154,8 +155,8 @@ bool Encryptor::CryptCTR(bool do_encrypt,
CHECK_GT(out_size + 1, input.size());
std::string result;
- uint8* out_ptr =
- reinterpret_cast<uint8*>(base::WriteInto(&result, out_size + 1));
+ uint8_t* out_ptr =
+ reinterpret_cast<uint8_t*>(base::WriteInto(&result, out_size + 1));
uint8_t ivec[AES_BLOCK_SIZE] = { 0 };
uint8_t ecount_buf[AES_BLOCK_SIZE] = { 0 };
@@ -163,7 +164,7 @@ bool Encryptor::CryptCTR(bool do_encrypt,
counter_->Write(ivec);
- AES_ctr128_encrypt(reinterpret_cast<const uint8*>(input.data()), out_ptr,
+ AES_ctr128_encrypt(reinterpret_cast<const uint8_t*>(input.data()), out_ptr,
input.size(), &aes_key, ivec, ecount_buf, &block_offset);
// AES_ctr128_encrypt() updates |ivec|. Update the |counter_| here.
diff --git a/crypto/encryptor_unittest.cc b/crypto/encryptor_unittest.cc
index 79fe2cc..93355f8 100644
--- a/crypto/encryptor_unittest.cc
+++ b/crypto/encryptor_unittest.cc
@@ -4,8 +4,11 @@
#include "crypto/encryptor.h"
+#include <stddef.h>
+
#include <string>
+#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "crypto/symmetric_key.h"
diff --git a/crypto/ghash.cc b/crypto/ghash.cc
index 1acd474..fcd513e 100644
--- a/crypto/ghash.cc
+++ b/crypto/ghash.cc
@@ -4,6 +4,9 @@
#include "crypto/ghash.h"
+#include <stddef.h>
+#include <stdint.h>
+
#include <algorithm>
#include "base/logging.h"
@@ -27,14 +30,14 @@ namespace crypto {
namespace {
// Get64 reads a 64-bit, big-endian number from |bytes|.
-uint64 Get64(const uint8 bytes[8]) {
- uint64 t;
+uint64_t Get64(const uint8_t bytes[8]) {
+ uint64_t t;
memcpy(&t, bytes, sizeof(t));
return base::NetToHost64(t);
}
// Put64 writes |x| to |bytes| as a 64-bit, big-endian number.
-void Put64(uint8 bytes[8], uint64 x) {
+void Put64(uint8_t bytes[8], uint64_t x) {
x = base::HostToNet64(x);
memcpy(bytes, &x, sizeof(x));
}
@@ -48,7 +51,7 @@ int Reverse(int i) {
} // namespace
-GaloisHash::GaloisHash(const uint8 key[16]) {
+GaloisHash::GaloisHash(const uint8_t key[16]) {
Reset();
// We precompute 16 multiples of |key|. However, when we do lookups into this
@@ -76,13 +79,13 @@ void GaloisHash::Reset() {
y_.hi = 0;
}
-void GaloisHash::UpdateAdditional(const uint8* data, size_t length) {
+void GaloisHash::UpdateAdditional(const uint8_t* data, size_t length) {
DCHECK_EQ(state_, kHashingAdditionalData);
additional_bytes_ += length;
Update(data, length);
}
-void GaloisHash::UpdateCiphertext(const uint8* data, size_t length) {
+void GaloisHash::UpdateCiphertext(const uint8_t* data, size_t length) {
if (state_ == kHashingAdditionalData) {
// If there's any remaining additional data it's zero padded to the next
// full block.
@@ -118,9 +121,9 @@ void GaloisHash::Finish(void* output, size_t len) {
y_.hi ^= ciphertext_bytes_*8;
MulAfterPrecomputation(product_table_, &y_);
- uint8 *result, result_tmp[16];
+ uint8_t *result, result_tmp[16];
if (len >= 16) {
- result = reinterpret_cast<uint8*>(output);
+ result = reinterpret_cast<uint8_t*>(output);
} else {
result = result_tmp;
}
@@ -177,7 +180,7 @@ void GaloisHash::MulAfterPrecomputation(const FieldElement* table,
// characteristic 2 fields, repeated doublings are exceptionally cheap and
// it's not worth spending more precomputation time to eliminate them.
for (unsigned i = 0; i < 2; i++) {
- uint64 word;
+ uint64_t word;
if (i == 0) {
word = x->hi;
} else {
@@ -205,9 +208,9 @@ void GaloisHash::MulAfterPrecomputation(const FieldElement* table,
// least-significant 8 bits, save for the term at x^128. Therefore we can
// precompute the value to be added to the field element for each of the 16 bit
// patterns at 2**128 and the values fit within 12 bits.
-static const uint16 kReductionTable[16] = {
- 0x0000, 0x1c20, 0x3840, 0x2460, 0x7080, 0x6ca0, 0x48c0, 0x54e0,
- 0xe100, 0xfd20, 0xd940, 0xc560, 0x9180, 0x8da0, 0xa9c0, 0xb5e0,
+static const uint16_t kReductionTable[16] = {
+ 0x0000, 0x1c20, 0x3840, 0x2460, 0x7080, 0x6ca0, 0x48c0, 0x54e0,
+ 0xe100, 0xfd20, 0xd940, 0xc560, 0x9180, 0x8da0, 0xa9c0, 0xb5e0,
};
// static
@@ -216,10 +219,10 @@ void GaloisHash::Mul16(FieldElement* x) {
x->hi >>= 4;
x->hi |= x->low << 60;
x->low >>= 4;
- x->low ^= static_cast<uint64>(kReductionTable[msw]) << 48;
+ x->low ^= static_cast<uint64_t>(kReductionTable[msw]) << 48;
}
-void GaloisHash::UpdateBlocks(const uint8* bytes, size_t num_blocks) {
+void GaloisHash::UpdateBlocks(const uint8_t* bytes, size_t num_blocks) {
for (size_t i = 0; i < num_blocks; i++) {
y_.low ^= Get64(bytes);
bytes += 8;
@@ -229,7 +232,7 @@ void GaloisHash::UpdateBlocks(const uint8* bytes, size_t num_blocks) {
}
}
-void GaloisHash::Update(const uint8* data, size_t length) {
+void GaloisHash::Update(const uint8_t* data, size_t length) {
if (buf_used_ > 0) {
const size_t n = std::min(length, sizeof(buf_) - buf_used_);
memcpy(&buf_[buf_used_], data, n);
diff --git a/crypto/ghash.h b/crypto/ghash.h
index 53f6b51..b123dfe 100644
--- a/crypto/ghash.h
+++ b/crypto/ghash.h
@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/basictypes.h"
+#include <stddef.h>
+#include <stdint.h>
+
#include "crypto/crypto_export.h"
namespace crypto {
@@ -27,7 +29,7 @@ namespace crypto {
// the implementation of AES that is used.
class CRYPTO_EXPORT GaloisHash {
public:
- explicit GaloisHash(const uint8 key[16]);
+ explicit GaloisHash(const uint8_t key[16]);
// Reset prepares to digest a fresh message with the same key. This is more
// efficient than creating a fresh object.
@@ -36,10 +38,10 @@ class CRYPTO_EXPORT GaloisHash {
// UpdateAdditional hashes in `additional' data. This is data that is not
// encrypted, but is covered by the authenticator. All additional data must
// be written before any ciphertext is written.
- void UpdateAdditional(const uint8* data, size_t length);
+ void UpdateAdditional(const uint8_t* data, size_t length);
// UpdateCiphertext hashes in ciphertext to be authenticated.
- void UpdateCiphertext(const uint8* data, size_t length);
+ void UpdateCiphertext(const uint8_t* data, size_t length);
// Finish completes the hash computation and writes at most |len| bytes of
// the result to |output|.
@@ -53,7 +55,7 @@ class CRYPTO_EXPORT GaloisHash {
};
struct FieldElement {
- uint64 low, hi;
+ uint64_t low, hi;
};
// Add returns |x|+|y|.
@@ -68,17 +70,17 @@ class CRYPTO_EXPORT GaloisHash {
static void Mul16(FieldElement* x);
// UpdateBlocks processes |num_blocks| 16-bytes blocks from |bytes|.
- void UpdateBlocks(const uint8* bytes, size_t num_blocks);
+ void UpdateBlocks(const uint8_t* bytes, size_t num_blocks);
// Update processes |length| bytes from |bytes| and calls UpdateBlocks on as
// much data as possible. It uses |buf_| to buffer any remaining data and
// always consumes all of |bytes|.
- void Update(const uint8* bytes, size_t length);
+ void Update(const uint8_t* bytes, size_t length);
FieldElement y_;
State state_;
size_t additional_bytes_;
size_t ciphertext_bytes_;
- uint8 buf_[16];
+ uint8_t buf_[16];
size_t buf_used_;
FieldElement product_table_[16];
};
diff --git a/crypto/ghash_unittest.cc b/crypto/ghash_unittest.cc
index 5dd88ed..01f9cf4 100644
--- a/crypto/ghash_unittest.cc
+++ b/crypto/ghash_unittest.cc
@@ -2,10 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <algorithm>
-
#include "crypto/ghash.h"
+#include <stddef.h>
+#include <stdint.h>
+
+#include <algorithm>
+
+#include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace crypto {
@@ -15,45 +19,42 @@ namespace {
// Test vectors are taken from Appendix B of
// http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf
-static const uint8 kKey1[16] = {
- 0x66, 0xe9, 0x4b, 0xd4, 0xef, 0x8a, 0x2c, 0x3b,
- 0x88, 0x4c, 0xfa, 0x59, 0xca, 0x34, 0x2b, 0x2e,
+static const uint8_t kKey1[16] = {
+ 0x66, 0xe9, 0x4b, 0xd4, 0xef, 0x8a, 0x2c, 0x3b,
+ 0x88, 0x4c, 0xfa, 0x59, 0xca, 0x34, 0x2b, 0x2e,
};
-static const uint8 kCiphertext2[] = {
- 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92,
- 0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78,
+static const uint8_t kCiphertext2[] = {
+ 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92,
+ 0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78,
};
-static const uint8 kKey3[16] = {
- 0xb8, 0x3b, 0x53, 0x37, 0x08, 0xbf, 0x53, 0x5d,
- 0x0a, 0xa6, 0xe5, 0x29, 0x80, 0xd5, 0x3b, 0x78,
+static const uint8_t kKey3[16] = {
+ 0xb8, 0x3b, 0x53, 0x37, 0x08, 0xbf, 0x53, 0x5d,
+ 0x0a, 0xa6, 0xe5, 0x29, 0x80, 0xd5, 0x3b, 0x78,
};
-static const uint8 kCiphertext3[] = {
- 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
- 0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
- 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
- 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
- 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
- 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
- 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
- 0x3d, 0x58, 0xe0, 0x91, 0x47, 0x3f, 0x59, 0x85,
+static const uint8_t kCiphertext3[] = {
+ 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, 0x4b, 0x72, 0x21,
+ 0xb7, 0x84, 0xd0, 0xd4, 0x9c, 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02,
+ 0xa4, 0xe0, 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e, 0x21,
+ 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c, 0x7d, 0x8f, 0x6a, 0x5a,
+ 0xac, 0x84, 0xaa, 0x05, 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac,
+ 0x97, 0x3d, 0x58, 0xe0, 0x91, 0x47, 0x3f, 0x59, 0x85,
};
-static const uint8 kAdditional4[] = {
- 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
- 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
- 0xab, 0xad, 0xda, 0xd2,
+static const uint8_t kAdditional4[] = {
+ 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed,
+ 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xab, 0xad, 0xda, 0xd2,
};
struct TestCase {
- const uint8* key;
- const uint8* additional;
+ const uint8_t* key;
+ const uint8_t* additional;
unsigned additional_length;
- const uint8* ciphertext;
+ const uint8_t* ciphertext;
unsigned ciphertext_length;
- const uint8 expected[16];
+ const uint8_t expected[16];
};
static const TestCase kTestCases[] = {
@@ -104,7 +105,7 @@ static const TestCase kTestCases[] = {
};
TEST(GaloisHash, TestCases) {
- uint8 out[16];
+ uint8_t out[16];
for (size_t i = 0; i < arraysize(kTestCases); ++i) {
const TestCase& test = kTestCases[i];
@@ -120,7 +121,7 @@ TEST(GaloisHash, TestCases) {
}
TEST(GaloisHash, VaryLengths) {
- uint8 out[16];
+ uint8_t out[16];
for (size_t chunk_size = 1; chunk_size < 16; chunk_size++) {
for (size_t i = 0; i < arraysize(kTestCases); ++i) {
diff --git a/crypto/hkdf.cc b/crypto/hkdf.cc
index 82aae24..67c3921 100644
--- a/crypto/hkdf.cc
+++ b/crypto/hkdf.cc
@@ -4,6 +4,9 @@
#include "crypto/hkdf.h"
+#include <stddef.h>
+#include <stdint.h>
+
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "crypto/hmac.h"
@@ -34,7 +37,7 @@ HKDF::HKDF(const base::StringPiece& secret,
DCHECK(result);
// |prk| is a pseudorandom key (of kSHA256HashLength octets).
- uint8 prk[kSHA256HashLength];
+ uint8_t prk[kSHA256HashLength];
DCHECK_EQ(sizeof(prk), prk_hmac.DigestLength());
result = prk_hmac.Sign(secret, prk, sizeof(prk));
DCHECK(result);
@@ -53,7 +56,7 @@ HKDF::HKDF(const base::StringPiece& secret,
base::StringPiece previous;
scoped_ptr<char[]> buf(new char[kSHA256HashLength + info.size() + 1]);
- uint8 digest[kSHA256HashLength];
+ uint8_t digest[kSHA256HashLength];
HMAC hmac(HMAC::SHA256);
result = hmac.Init(prk, sizeof(prk));
diff --git a/crypto/hkdf.h b/crypto/hkdf.h
index e91bccf..6b7d00d 100644
--- a/crypto/hkdf.h
+++ b/crypto/hkdf.h
@@ -5,9 +5,11 @@
#ifndef CRYPTO_HKDF_H_
#define CRYPTO_HKDF_H_
+#include <stddef.h>
+#include <stdint.h>
+
#include <vector>
-#include "base/basictypes.h"
#include "base/strings/string_piece.h"
#include "crypto/crypto_export.h"
@@ -57,7 +59,7 @@ class CRYPTO_EXPORT HKDF {
}
private:
- std::vector<uint8> output_;
+ std::vector<uint8_t> output_;
base::StringPiece client_write_key_;
base::StringPiece server_write_key_;
diff --git a/crypto/hkdf_unittest.cc b/crypto/hkdf_unittest.cc
index bcb19c5..0412703 100644
--- a/crypto/hkdf_unittest.cc
+++ b/crypto/hkdf_unittest.cc
@@ -4,8 +4,12 @@
#include "crypto/hkdf.h"
+#include <stddef.h>
+#include <stdint.h>
+
#include <string>
+#include "base/macros.h"
#include "base/strings/string_number_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -56,7 +60,7 @@ TEST(HKDFTest, HKDF) {
const HKDFTest& test(kHKDFTests[i]);
SCOPED_TRACE(i);
- std::vector<uint8> data;
+ std::vector<uint8_t> data;
ASSERT_TRUE(base::HexStringToBytes(test.key_hex, &data));
const std::string key(reinterpret_cast<char*>(&data[0]), data.size());
diff --git a/crypto/hmac.cc b/crypto/hmac.cc
index c9a2b74..e9869b4 100644
--- a/crypto/hmac.cc
+++ b/crypto/hmac.cc
@@ -4,6 +4,8 @@
#include "crypto/hmac.h"
+#include <stddef.h>
+
#include <algorithm>
#include "base/logging.h"
diff --git a/crypto/hmac.h b/crypto/hmac.h
index c7b22fa..ccdab30 100644
--- a/crypto/hmac.h
+++ b/crypto/hmac.h
@@ -8,8 +8,10 @@
#ifndef CRYPTO_HMAC_H_
#define CRYPTO_HMAC_H_
-#include "base/basictypes.h"
+#include <stddef.h>
+
#include "base/compiler_specific.h"
+#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
#include "crypto/crypto_export.h"
diff --git a/crypto/hmac_nss.cc b/crypto/hmac_nss.cc
index e14282c..9d759b5d 100644
--- a/crypto/hmac_nss.cc
+++ b/crypto/hmac_nss.cc
@@ -6,6 +6,7 @@
#include <nss.h>
#include <pk11pub.h>
+#include <stddef.h>
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
diff --git a/crypto/hmac_openssl.cc b/crypto/hmac_openssl.cc
index 8f043f1..8c8c11a 100644
--- a/crypto/hmac_openssl.cc
+++ b/crypto/hmac_openssl.cc
@@ -5,6 +5,7 @@
#include "crypto/hmac.h"
#include <openssl/hmac.h>
+#include <stddef.h>
#include <algorithm>
#include <vector>
diff --git a/crypto/hmac_unittest.cc b/crypto/hmac_unittest.cc
index 91eccd6..f8dbd5a 100644
--- a/crypto/hmac_unittest.cc
+++ b/crypto/hmac_unittest.cc
@@ -2,8 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <stddef.h>
+
#include <string>
+#include "base/macros.h"
#include "crypto/hmac.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/crypto/hmac_win.cc b/crypto/hmac_win.cc
index 99b3a60..ab29081 100644
--- a/crypto/hmac_win.cc
+++ b/crypto/hmac_win.cc
@@ -5,6 +5,7 @@
#include "crypto/hmac.h"
#include <windows.h>
+#include <stddef.h>
#include <algorithm>
#include <vector>
diff --git a/crypto/mac_security_services_lock.cc b/crypto/mac_security_services_lock.cc
index af66918..902a871 100644
--- a/crypto/mac_security_services_lock.cc
+++ b/crypto/mac_security_services_lock.cc
@@ -4,6 +4,7 @@
#include "crypto/mac_security_services_lock.h"
+#include "base/macros.h"
#include "base/memory/singleton.h"
#include "base/synchronization/lock.h"
diff --git a/crypto/mock_apple_keychain.cc b/crypto/mock_apple_keychain.cc
index a1faa65..dd3d7c5 100644
--- a/crypto/mock_apple_keychain.cc
+++ b/crypto/mock_apple_keychain.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/logging.h"
+#include "base/macros.h"
#include "base/metrics/histogram.h"
#include "base/time/time.h"
#include "crypto/mock_apple_keychain.h"
diff --git a/crypto/mock_apple_keychain.h b/crypto/mock_apple_keychain.h
index f73d3a6..f36e982 100644
--- a/crypto/mock_apple_keychain.h
+++ b/crypto/mock_apple_keychain.h
@@ -5,6 +5,7 @@
#ifndef CRYPTO_MOCK_KEYCHAIN_MAC_H_
#define CRYPTO_MOCK_KEYCHAIN_MAC_H_
+#include <stddef.h>
#include <stdint.h>
#include <map>
diff --git a/crypto/mock_apple_keychain_mac.cc b/crypto/mock_apple_keychain_mac.cc
index 5f33e5b..e4bc30c 100644
--- a/crypto/mock_apple_keychain_mac.cc
+++ b/crypto/mock_apple_keychain_mac.cc
@@ -2,7 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <stddef.h>
+
#include "base/logging.h"
+#include "base/macros.h"
#include "base/time/time.h"
#include "crypto/mock_apple_keychain.h"
diff --git a/crypto/nss_key_util.cc b/crypto/nss_key_util.cc
index 7a5d6b4..f48cb0f 100644
--- a/crypto/nss_key_util.cc
+++ b/crypto/nss_key_util.cc
@@ -7,6 +7,7 @@
#include <cryptohi.h>
#include <keyhi.h>
#include <pk11pub.h>
+#include <stdint.h>
#include "base/logging.h"
#include "crypto/nss_util.h"
diff --git a/crypto/nss_key_util_unittest.cc b/crypto/nss_key_util_unittest.cc
index ff4d55a..99b52a9 100644
--- a/crypto/nss_key_util_unittest.cc
+++ b/crypto/nss_key_util_unittest.cc
@@ -6,6 +6,7 @@
#include <keyhi.h>
#include <pk11pub.h>
+#include <stdint.h>
#include <vector>
diff --git a/crypto/nss_util.h b/crypto/nss_util.h
index 06c1e5d..71e5a67 100644
--- a/crypto/nss_util.h
+++ b/crypto/nss_util.h
@@ -5,10 +5,12 @@
#ifndef CRYPTO_NSS_UTIL_H_
#define CRYPTO_NSS_UTIL_H_
+#include <stdint.h>
+
#include <string>
-#include "base/basictypes.h"
#include "base/callback.h"
#include "base/compiler_specific.h"
+#include "base/macros.h"
#include "crypto/crypto_export.h"
namespace base {
@@ -72,12 +74,12 @@ CRYPTO_EXPORT void InitializeTPMTokenAndSystemSlot(
#endif
// Convert a NSS PRTime value into a base::Time object.
-// We use a int64 instead of PRTime here to avoid depending on NSPR headers.
-CRYPTO_EXPORT base::Time PRTimeToBaseTime(int64 prtime);
+// We use a int64_t instead of PRTime here to avoid depending on NSPR headers.
+CRYPTO_EXPORT base::Time PRTimeToBaseTime(int64_t prtime);
// Convert a base::Time object into a PRTime value.
-// We use a int64 instead of PRTime here to avoid depending on NSPR headers.
-CRYPTO_EXPORT int64 BaseTimeToPRTime(base::Time time);
+// We use a int64_t instead of PRTime here to avoid depending on NSPR headers.
+CRYPTO_EXPORT int64_t BaseTimeToPRTime(base::Time time);
#if defined(USE_NSS_CERTS)
// NSS has a bug which can cause a deadlock or stall in some cases when writing
diff --git a/crypto/nss_util_internal.h b/crypto/nss_util_internal.h
index 17d6187..0982a6e8 100644
--- a/crypto/nss_util_internal.h
+++ b/crypto/nss_util_internal.h
@@ -9,6 +9,7 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
+#include "base/macros.h"
#include "crypto/crypto_export.h"
#include "crypto/scoped_nss_types.h"
diff --git a/crypto/openssl_util.cc b/crypto/openssl_util.cc
index f5b20c9..48ec3e2 100644
--- a/crypto/openssl_util.cc
+++ b/crypto/openssl_util.cc
@@ -7,8 +7,11 @@
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <openssl/cpu.h>
+#include <stddef.h>
+#include <stdint.h>
#include "base/logging.h"
+#include "base/macros.h"
#include "base/memory/singleton.h"
#include "base/strings/string_piece.h"
#include "build/build_config.h"
diff --git a/crypto/openssl_util.h b/crypto/openssl_util.h
index 2743883..78fa66e 100644
--- a/crypto/openssl_util.h
+++ b/crypto/openssl_util.h
@@ -5,8 +5,10 @@
#ifndef CRYPTO_OPENSSL_UTIL_H_
#define CRYPTO_OPENSSL_UTIL_H_
-#include "base/basictypes.h"
+#include <stddef.h>
+
#include "base/location.h"
+#include "base/macros.h"
#include "crypto/crypto_export.h"
namespace crypto {
diff --git a/crypto/p224.cc b/crypto/p224.cc
index a86163f..685a335 100644
--- a/crypto/p224.cc
+++ b/crypto/p224.cc
@@ -9,6 +9,8 @@
#include "crypto/p224.h"
+#include <stddef.h>
+#include <stdint.h>
#include <string.h>
#include "base/sys_byteorder.h"
@@ -23,7 +25,7 @@ using base::NetToHost32;
// The field that we're dealing with is ℤ/pℤ where p = 2**224 - 2**96 + 1.
//
// Field elements are represented by a FieldElement, which is a typedef to an
-// array of 8 uint32's. The value of a FieldElement, a, is:
+// array of 8 uint32_t's. The value of a FieldElement, a, is:
// a[0] + 2**28·a[1] + 2**56·a[1] + ... + 2**196·a[7]
//
// Using 28-bit limbs means that there's only 4 bits of headroom, which is less
@@ -41,12 +43,12 @@ const FieldElement kP = {
void Contract(FieldElement* inout);
// IsZero returns 0xffffffff if a == 0 mod p and 0 otherwise.
-uint32 IsZero(const FieldElement& a) {
+uint32_t IsZero(const FieldElement& a) {
FieldElement minimal;
memcpy(&minimal, &a, sizeof(minimal));
Contract(&minimal);
- uint32 is_zero = 0, is_p = 0;
+ uint32_t is_zero = 0, is_p = 0;
for (unsigned i = 0; i < 8; i++) {
is_zero |= minimal[i];
is_p |= minimal[i] - kP[i];
@@ -68,7 +70,7 @@ uint32 IsZero(const FieldElement& a) {
// For is_zero and is_p, the LSB is 0 iff all the bits are zero.
is_zero &= is_p & 1;
is_zero = (~is_zero) << 31;
- is_zero = static_cast<int32>(is_zero) >> 31;
+ is_zero = static_cast<int32_t>(is_zero) >> 31;
return is_zero;
}
@@ -81,9 +83,9 @@ void Add(FieldElement* out, const FieldElement& a, const FieldElement& b) {
}
}
-static const uint32 kTwo31p3 = (1u<<31) + (1u<<3);
-static const uint32 kTwo31m3 = (1u<<31) - (1u<<3);
-static const uint32 kTwo31m15m3 = (1u<<31) - (1u<<15) - (1u<<3);
+static const uint32_t kTwo31p3 = (1u << 31) + (1u << 3);
+static const uint32_t kTwo31m3 = (1u << 31) - (1u << 3);
+static const uint32_t kTwo31m15m3 = (1u << 31) - (1u << 15) - (1u << 3);
// kZero31ModP is 0 mod p where bit 31 is set in all limbs so that we can
// subtract smaller amounts without underflow. See the section "Subtraction" in
// [1] for why.
@@ -103,22 +105,22 @@ void Subtract(FieldElement* out, const FieldElement& a, const FieldElement& b) {
}
}
-static const uint64 kTwo63p35 = (1ull<<63) + (1ull<<35);
-static const uint64 kTwo63m35 = (1ull<<63) - (1ull<<35);
-static const uint64 kTwo63m35m19 = (1ull<<63) - (1ull<<35) - (1ull<<19);
+static const uint64_t kTwo63p35 = (1ull << 63) + (1ull << 35);
+static const uint64_t kTwo63m35 = (1ull << 63) - (1ull << 35);
+static const uint64_t kTwo63m35m19 = (1ull << 63) - (1ull << 35) - (1ull << 19);
// kZero63ModP is 0 mod p where bit 63 is set in all limbs. See the section
// "Subtraction" in [1] for why.
-static const uint64 kZero63ModP[8] = {
- kTwo63p35, kTwo63m35, kTwo63m35, kTwo63m35,
- kTwo63m35m19, kTwo63m35, kTwo63m35, kTwo63m35,
+static const uint64_t kZero63ModP[8] = {
+ kTwo63p35, kTwo63m35, kTwo63m35, kTwo63m35,
+ kTwo63m35m19, kTwo63m35, kTwo63m35, kTwo63m35,
};
-static const uint32 kBottom28Bits = 0xfffffff;
+static const uint32_t kBottom28Bits = 0xfffffff;
// LargeFieldElement also represents an element of the field. The limbs are
// still spaced 28-bits apart and in little-endian order. So the limbs are at
// 0, 28, 56, ..., 392 bits, each 64-bits wide.
-typedef uint64 LargeFieldElement[15];
+typedef uint64_t LargeFieldElement[15];
// ReduceLarge converts a LargeFieldElement to a FieldElement.
//
@@ -144,21 +146,21 @@ void ReduceLarge(FieldElement* out, LargeFieldElement* inptr) {
// 32-bit operations.
for (int i = 1; i < 8; i++) {
in[i+1] += in[i] >> 28;
- (*out)[i] = static_cast<uint32>(in[i] & kBottom28Bits);
+ (*out)[i] = static_cast<uint32_t>(in[i] & kBottom28Bits);
}
// Eliminate the term at 2*224 that we introduced while keeping the same
// value mod p.
in[0] -= in[8]; // reflection off the "+1" term of p.
- (*out)[3] += static_cast<uint32>(in[8] & 0xffff) << 12; // "-2**96" term
- (*out)[4] += static_cast<uint32>(in[8] >> 16); // rest of "-2**96" term
+ (*out)[3] += static_cast<uint32_t>(in[8] & 0xffff) << 12; // "-2**96" term
+ (*out)[4] += static_cast<uint32_t>(in[8] >> 16); // rest of "-2**96" term
// in[0] < 2**64
// out[3] < 2**29
// out[4] < 2**29
// out[1,2,5..7] < 2**28
- (*out)[0] = static_cast<uint32>(in[0] & kBottom28Bits);
- (*out)[1] += static_cast<uint32>((in[0] >> 28) & kBottom28Bits);
- (*out)[2] += static_cast<uint32>(in[0] >> 56);
+ (*out)[0] = static_cast<uint32_t>(in[0] & kBottom28Bits);
+ (*out)[1] += static_cast<uint32_t>((in[0] >> 28) & kBottom28Bits);
+ (*out)[2] += static_cast<uint32_t>(in[0] >> 56);
// out[0] < 2**28
// out[1..4] < 2**29
// out[5..7] < 2**28
@@ -174,7 +176,7 @@ void Mul(FieldElement* out, const FieldElement& a, const FieldElement& b) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
- tmp[i+j] += static_cast<uint64>(a[i]) * static_cast<uint64>(b[j]);
+ tmp[i + j] += static_cast<uint64_t>(a[i]) * static_cast<uint64_t>(b[j]);
}
}
@@ -191,7 +193,7 @@ void Square(FieldElement* out, const FieldElement& a) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j <= i; j++) {
- uint64 r = static_cast<uint64>(a[i]) * static_cast<uint64>(a[j]);
+ uint64_t r = static_cast<uint64_t>(a[i]) * static_cast<uint64_t>(a[j]);
if (i == j) {
tmp[i+j] += r;
} else {
@@ -214,16 +216,16 @@ void Reduce(FieldElement* in_out) {
a[i+1] += a[i] >> 28;
a[i] &= kBottom28Bits;
}
- uint32 top = a[7] >> 28;
+ uint32_t top = a[7] >> 28;
a[7] &= kBottom28Bits;
// top < 2**4
// Constant-time: mask = (top != 0) ? 0xffffffff : 0
- uint32 mask = top;
+ uint32_t mask = top;
mask |= mask >> 2;
mask |= mask >> 1;
mask <<= 31;
- mask = static_cast<uint32>(static_cast<int32>(mask) >> 31);
+ mask = static_cast<uint32_t>(static_cast<int32_t>(mask) >> 31);
// Eliminate top while maintaining the same value mod p.
a[0] -= top;
@@ -300,7 +302,7 @@ void Contract(FieldElement* inout) {
out[i+1] += out[i] >> 28;
out[i] &= kBottom28Bits;
}
- uint32 top = out[7] >> 28;
+ uint32_t top = out[7] >> 28;
out[7] &= kBottom28Bits;
// Eliminate top while maintaining the same value mod p.
@@ -311,7 +313,7 @@ void Contract(FieldElement* inout) {
// out[0] negative then we know that out[3] is sufficiently positive
// because we just added to it.
for (int i = 0; i < 3; i++) {
- uint32 mask = static_cast<uint32>(static_cast<int32>(out[i]) >> 31);
+ uint32_t mask = static_cast<uint32_t>(static_cast<int32_t>(out[i]) >> 31);
out[i] += (1 << 28) & mask;
out[i+1] -= 1 & mask;
}
@@ -344,7 +346,7 @@ void Contract(FieldElement* inout) {
// As before, if we made out[0] negative then we know that out[3] is
// sufficiently positive.
for (int i = 0; i < 3; i++) {
- uint32 mask = static_cast<uint32>(static_cast<int32>(out[i]) >> 31);
+ uint32_t mask = static_cast<uint32_t>(static_cast<int32_t>(out[i]) >> 31);
out[i] += (1 << 28) & mask;
out[i+1] -= 1 & mask;
}
@@ -356,7 +358,7 @@ void Contract(FieldElement* inout) {
// equal to bottom28Bits if the whole value is >= p. If top_4_all_ones
// ends up with any zero bits in the bottom 28 bits, then this wasn't
// true.
- uint32 top_4_all_ones = 0xffffffffu;
+ uint32_t top_4_all_ones = 0xffffffffu;
for (int i = 4; i < 8; i++) {
top_4_all_ones &= out[i];
}
@@ -368,37 +370,39 @@ void Contract(FieldElement* inout) {
top_4_all_ones &= top_4_all_ones >> 2;
top_4_all_ones &= top_4_all_ones >> 1;
top_4_all_ones =
- static_cast<uint32>(static_cast<int32>(top_4_all_ones << 31) >> 31);
+ static_cast<uint32_t>(static_cast<int32_t>(top_4_all_ones << 31) >> 31);
// Now we test whether the bottom three limbs are non-zero.
- uint32 bottom_3_non_zero = out[0] | out[1] | out[2];
+ uint32_t bottom_3_non_zero = out[0] | out[1] | out[2];
bottom_3_non_zero |= bottom_3_non_zero >> 16;
bottom_3_non_zero |= bottom_3_non_zero >> 8;
bottom_3_non_zero |= bottom_3_non_zero >> 4;
bottom_3_non_zero |= bottom_3_non_zero >> 2;
bottom_3_non_zero |= bottom_3_non_zero >> 1;
bottom_3_non_zero =
- static_cast<uint32>(static_cast<int32>(bottom_3_non_zero) >> 31);
+ static_cast<uint32_t>(static_cast<int32_t>(bottom_3_non_zero) >> 31);
// Everything depends on the value of out[3].
// If it's > 0xffff000 and top_4_all_ones != 0 then the whole value is >= p
// If it's = 0xffff000 and top_4_all_ones != 0 and bottom_3_non_zero != 0,
// then the whole value is >= p
// If it's < 0xffff000, then the whole value is < p
- uint32 n = out[3] - 0xffff000;
- uint32 out_3_equal = n;
+ uint32_t n = out[3] - 0xffff000;
+ uint32_t out_3_equal = n;
out_3_equal |= out_3_equal >> 16;
out_3_equal |= out_3_equal >> 8;
out_3_equal |= out_3_equal >> 4;
out_3_equal |= out_3_equal >> 2;
out_3_equal |= out_3_equal >> 1;
out_3_equal =
- ~static_cast<uint32>(static_cast<int32>(out_3_equal << 31) >> 31);
+ ~static_cast<uint32_t>(static_cast<int32_t>(out_3_equal << 31) >> 31);
// If out[3] > 0xffff000 then n's MSB will be zero.
- uint32 out_3_gt = ~static_cast<uint32>(static_cast<int32>(n << 31) >> 31);
+ uint32_t out_3_gt =
+ ~static_cast<uint32_t>(static_cast<int32_t>(n << 31) >> 31);
- uint32 mask = top_4_all_ones & ((out_3_equal & bottom_3_non_zero) | out_3_gt);
+ uint32_t mask =
+ top_4_all_ones & ((out_3_equal & bottom_3_non_zero) | out_3_gt);
out[0] -= 1 & mask;
out[3] -= 0xffff000 & mask;
out[4] -= 0xfffffff & mask;
@@ -421,7 +425,7 @@ const FieldElement kB = {
39211076, 180311059, 84673715, 188764328,
};
-void CopyConditional(Point* out, const Point& a, uint32 mask);
+void CopyConditional(Point* out, const Point& a, uint32_t mask);
void DoubleJacobian(Point* out, const Point& a);
// AddJacobian computes *out = a+b where a != b.
@@ -431,8 +435,8 @@ void AddJacobian(Point *out,
// See http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#addition-add-2007-bl
FieldElement z1z1, z2z2, u1, u2, s1, s2, h, i, j, r, v;
- uint32 z1_is_zero = IsZero(a.z);
- uint32 z2_is_zero = IsZero(b.z);
+ uint32_t z1_is_zero = IsZero(a.z);
+ uint32_t z2_is_zero = IsZero(b.z);
// Z1Z1 = Z1²
Square(&z1z1, a.z);
@@ -457,7 +461,7 @@ void AddJacobian(Point *out,
// H = U2-U1
Subtract(&h, u2, u1);
Reduce(&h);
- uint32 x_equal = IsZero(h);
+ uint32_t x_equal = IsZero(h);
// I = (2*H)²
for (int k = 0; k < 8; k++) {
@@ -471,7 +475,7 @@ void AddJacobian(Point *out,
// r = 2*(S2-S1)
Subtract(&r, s2, s1);
Reduce(&r);
- uint32 y_equal = IsZero(r);
+ uint32_t y_equal = IsZero(r);
if (x_equal && y_equal && !z1_is_zero && !z2_is_zero) {
// The two input points are the same therefore we must use the dedicated
@@ -578,9 +582,7 @@ void DoubleJacobian(Point* out, const Point& a) {
// CopyConditional sets *out=a if mask is 0xffffffff. mask must be either 0 of
// 0xffffffff.
-void CopyConditional(Point* out,
- const Point& a,
- uint32 mask) {
+void CopyConditional(Point* out, const Point& a, uint32_t mask) {
for (int i = 0; i < 8; i++) {
out->x[i] ^= mask & (a.x[i] ^ out->x[i]);
out->y[i] ^= mask & (a.y[i] ^ out->y[i]);
@@ -590,15 +592,17 @@ void CopyConditional(Point* out,
// ScalarMult calculates *out = a*scalar where scalar is a big-endian number of
// length scalar_len and != 0.
-void ScalarMult(Point* out, const Point& a,
- const uint8* scalar, size_t scalar_len) {
+void ScalarMult(Point* out,
+ const Point& a,
+ const uint8_t* scalar,
+ size_t scalar_len) {
memset(out, 0, sizeof(*out));
Point tmp;
for (size_t i = 0; i < scalar_len; i++) {
for (unsigned int bit_num = 0; bit_num < 8; bit_num++) {
DoubleJacobian(out, *out);
- uint32 bit = static_cast<uint32>(static_cast<int32>(
+ uint32_t bit = static_cast<uint32_t>(static_cast<int32_t>(
(((scalar[i] >> (7 - bit_num)) & 1) << 31) >> 31));
AddJacobian(&tmp, a, *out);
CopyConditional(out, tmp, bit);
@@ -608,7 +612,7 @@ void ScalarMult(Point* out, const Point& a,
// Get224Bits reads 7 words from in and scatters their contents in
// little-endian form into 8 words at out, 28 bits per output word.
-void Get224Bits(uint32* out, const uint32* in) {
+void Get224Bits(uint32_t* out, const uint32_t* in) {
out[0] = NetToHost32(in[6]) & kBottom28Bits;
out[1] = ((NetToHost32(in[5]) << 4) |
(NetToHost32(in[6]) >> 28)) & kBottom28Bits;
@@ -628,7 +632,7 @@ void Get224Bits(uint32* out, const uint32* in) {
// Put224Bits performs the inverse operation to Get224Bits: taking 28 bits from
// each of 8 input words and writing them in big-endian order to 7 words at
// out.
-void Put224Bits(uint32* out, const uint32* in) {
+void Put224Bits(uint32_t* out, const uint32_t* in) {
out[6] = HostToNet32((in[0] >> 0) | (in[1] << 28));
out[5] = HostToNet32((in[1] >> 4) | (in[2] << 24));
out[4] = HostToNet32((in[2] >> 8) | (in[3] << 20));
@@ -647,7 +651,7 @@ namespace p224 {
bool Point::SetFromString(const base::StringPiece& in) {
if (in.size() != 2*28)
return false;
- const uint32* inwords = reinterpret_cast<const uint32*>(in.data());
+ const uint32_t* inwords = reinterpret_cast<const uint32_t*>(in.data());
Get224Bits(x, inwords);
Get224Bits(y, inwords + 7);
memset(&z, 0, sizeof(z));
@@ -693,13 +697,13 @@ std::string Point::ToString() const {
Contract(&xx);
Contract(&yy);
- uint32 outwords[14];
+ uint32_t outwords[14];
Put224Bits(outwords, xx);
Put224Bits(outwords + 7, yy);
return std::string(reinterpret_cast<const char*>(outwords), sizeof(outwords));
}
-void ScalarMult(const Point& in, const uint8* scalar, Point* out) {
+void ScalarMult(const Point& in, const uint8_t* scalar, Point* out) {
::ScalarMult(out, in, scalar, 28);
}
@@ -712,7 +716,7 @@ static const Point kBasePoint = {
{1, 0, 0, 0, 0, 0, 0, 0},
};
-void ScalarBaseMult(const uint8* scalar, Point* out) {
+void ScalarBaseMult(const uint8_t* scalar, Point* out) {
::ScalarMult(out, kBasePoint, scalar, 28);
}
diff --git a/crypto/p224.h b/crypto/p224.h
index 2efecfa..e9a53a9 100644
--- a/crypto/p224.h
+++ b/crypto/p224.h
@@ -5,9 +5,11 @@
#ifndef CRYPTO_P224_H_
#define CRYPTO_P224_H_
+#include <stddef.h>
+#include <stdint.h>
+
#include <string>
-#include "base/basictypes.h"
#include "base/strings/string_piece.h"
#include "crypto/crypto_export.h"
@@ -19,7 +21,7 @@ namespace p224 {
// An element of the field (ℤ/pℤ) is represented with 8, 28-bit limbs in
// little endian order.
-typedef uint32 FieldElement[8];
+typedef uint32_t FieldElement[8];
struct CRYPTO_EXPORT Point {
// SetFromString the value of the point from the 56 byte, external
@@ -41,11 +43,13 @@ static const size_t kScalarBytes = 28;
// ScalarMult computes *out = in*scalar where scalar is a 28-byte, big-endian
// number.
-void CRYPTO_EXPORT ScalarMult(const Point& in, const uint8* scalar, Point* out);
+void CRYPTO_EXPORT ScalarMult(const Point& in,
+ const uint8_t* scalar,
+ Point* out);
// ScalarBaseMult computes *out = g*scalar where g is the base point of the
// curve and scalar is a 28-byte, big-endian number.
-void CRYPTO_EXPORT ScalarBaseMult(const uint8* scalar, Point* out);
+void CRYPTO_EXPORT ScalarBaseMult(const uint8_t* scalar, Point* out);
// Add computes *out = a+b.
void CRYPTO_EXPORT Add(const Point& a, const Point& b, Point* out);
diff --git a/crypto/p224_spake.cc b/crypto/p224_spake.cc
index a6dec40..1574105 100644
--- a/crypto/p224_spake.cc
+++ b/crypto/p224_spake.cc
@@ -203,14 +203,14 @@ P224EncryptedKeyExchange::Result P224EncryptedKeyExchange::ProcessMessage(
// Now we calculate the hashes that each side will use to prove to the other
// that they derived the correct value for K.
- uint8 client_hash[kSHA256Length], server_hash[kSHA256Length];
+ uint8_t client_hash[kSHA256Length], server_hash[kSHA256Length];
CalculateHash(kPeerTypeClient, client_masked_dh, server_masked_dh, key_,
client_hash);
CalculateHash(kPeerTypeServer, client_masked_dh, server_masked_dh, key_,
server_hash);
- const uint8* my_hash = is_server_ ? server_hash : client_hash;
- const uint8* their_hash = is_server_ ? client_hash : server_hash;
+ const uint8_t* my_hash = is_server_ ? server_hash : client_hash;
+ const uint8_t* their_hash = is_server_ ? client_hash : server_hash;
next_message_ =
std::string(reinterpret_cast<const char*>(my_hash), kSHA256Length);
@@ -224,7 +224,7 @@ void P224EncryptedKeyExchange::CalculateHash(
const std::string& client_masked_dh,
const std::string& server_masked_dh,
const std::string& k,
- uint8* out_digest) {
+ uint8_t* out_digest) {
std::string hash_contents;
if (peer_type == kPeerTypeServer) {
diff --git a/crypto/p224_spake.h b/crypto/p224_spake.h
index 556b15c..f9a44e7 100644
--- a/crypto/p224_spake.h
+++ b/crypto/p224_spake.h
@@ -5,10 +5,12 @@
#ifndef CRYPTO_P224_SPAKE_H_
#define CRYPTO_P224_SPAKE_H_
-#include <base/gtest_prod_util.h>
-#include <base/strings/string_piece.h>
#include <crypto/p224.h>
#include <crypto/sha2.h>
+#include <stdint.h>
+
+#include "base/gtest_prod_util.h"
+#include "base/strings/string_piece.h"
namespace crypto {
@@ -101,22 +103,21 @@ class CRYPTO_EXPORT P224EncryptedKeyExchange {
// CalculateHash computes the verification hash for the given peer and writes
// |kSHA256Length| bytes at |out_digest|.
- void CalculateHash(
- PeerType peer_type,
- const std::string& client_masked_dh,
- const std::string& server_masked_dh,
- const std::string& k,
- uint8* out_digest);
+ void CalculateHash(PeerType peer_type,
+ const std::string& client_masked_dh,
+ const std::string& server_masked_dh,
+ const std::string& k,
+ uint8_t* out_digest);
// x_ is the secret Diffie-Hellman exponent (see paper referenced in .cc
// file).
- uint8 x_[p224::kScalarBytes];
- // pw_ is SHA256(P(password), P(session))[:28] where P() prepends a uint32,
+ uint8_t x_[p224::kScalarBytes];
+ // pw_ is SHA256(P(password), P(session))[:28] where P() prepends a uint32_t,
// big-endian length prefix (see paper referenced in .cc file).
- uint8 pw_[p224::kScalarBytes];
+ uint8_t pw_[p224::kScalarBytes];
// expected_authenticator_ is used to store the hash value expected from the
// other party.
- uint8 expected_authenticator_[kSHA256Length];
+ uint8_t expected_authenticator_[kSHA256Length];
std::string key_;
};
diff --git a/crypto/p224_spake_unittest.cc b/crypto/p224_spake_unittest.cc
index 15b5be2..3bca430 100644
--- a/crypto/p224_spake_unittest.cc
+++ b/crypto/p224_spake_unittest.cc
@@ -4,6 +4,9 @@
#include "crypto/p224_spake.h"
+#include <stddef.h>
+#include <stdint.h>
+
#include <string>
#include "base/logging.h"
@@ -125,7 +128,7 @@ TEST(MutualAuth, Fuzz) {
// We'll only be testing small values of i, but we don't want that to bias
// the test coverage. So we disperse the value of i by multiplying by the
// FNV, 32-bit prime, producing a poor-man's PRNG.
- const uint32 rand = i * 16777619;
+ const uint32_t rand = i * 16777619;
for (unsigned round = 0;; round++) {
std::string client_message, server_message;
diff --git a/crypto/p224_unittest.cc b/crypto/p224_unittest.cc
index aaf5f59..faa08eb 100644
--- a/crypto/p224_unittest.cc
+++ b/crypto/p224_unittest.cc
@@ -2,11 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <string.h>
+#include <stddef.h>
+#include <stdint.h>
#include <stdio.h>
+#include <string.h>
#include "crypto/p224.h"
+#include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace crypto {
@@ -14,22 +17,20 @@ namespace crypto {
using p224::Point;
// kBasePointExternal is the P224 base point in external representation.
-static const uint8 kBasePointExternal[56] = {
- 0xb7, 0x0e, 0x0c, 0xbd, 0x6b, 0xb4, 0xbf, 0x7f,
- 0x32, 0x13, 0x90, 0xb9, 0x4a, 0x03, 0xc1, 0xd3,
- 0x56, 0xc2, 0x11, 0x22, 0x34, 0x32, 0x80, 0xd6,
- 0x11, 0x5c, 0x1d, 0x21, 0xbd, 0x37, 0x63, 0x88,
- 0xb5, 0xf7, 0x23, 0xfb, 0x4c, 0x22, 0xdf, 0xe6,
- 0xcd, 0x43, 0x75, 0xa0, 0x5a, 0x07, 0x47, 0x64,
- 0x44, 0xd5, 0x81, 0x99, 0x85, 0x00, 0x7e, 0x34,
+static const uint8_t kBasePointExternal[56] = {
+ 0xb7, 0x0e, 0x0c, 0xbd, 0x6b, 0xb4, 0xbf, 0x7f, 0x32, 0x13, 0x90, 0xb9,
+ 0x4a, 0x03, 0xc1, 0xd3, 0x56, 0xc2, 0x11, 0x22, 0x34, 0x32, 0x80, 0xd6,
+ 0x11, 0x5c, 0x1d, 0x21, 0xbd, 0x37, 0x63, 0x88, 0xb5, 0xf7, 0x23, 0xfb,
+ 0x4c, 0x22, 0xdf, 0xe6, 0xcd, 0x43, 0x75, 0xa0, 0x5a, 0x07, 0x47, 0x64,
+ 0x44, 0xd5, 0x81, 0x99, 0x85, 0x00, 0x7e, 0x34,
};
// TestVector represents a test of scalar multiplication of the base point.
// |scalar| is a big-endian scalar and |affine| is the external representation
// of g*scalar.
struct TestVector {
- uint8 scalar[28];
- uint8 affine[28*2];
+ uint8_t scalar[28];
+ uint8_t affine[28 * 2];
};
static const int kNumNISTTestVectors = 52;
@@ -814,7 +815,7 @@ TEST(P224, Infinity) {
// Test that x^0 = ∞.
Point a;
- p224::ScalarBaseMult(reinterpret_cast<const uint8*>(zeros), &a);
+ p224::ScalarBaseMult(reinterpret_cast<const uint8_t*>(zeros), &a);
EXPECT_TRUE(memcmp(zeros, a.ToString().data(), sizeof(zeros)) == 0);
// We shouldn't allow ∞ to be imported.
diff --git a/crypto/random.cc b/crypto/random.cc
index a19bb1a..355914e 100644
--- a/crypto/random.cc
+++ b/crypto/random.cc
@@ -4,6 +4,8 @@
#include "crypto/random.h"
+#include <stddef.h>
+
#include "base/rand_util.h"
namespace crypto {
diff --git a/crypto/random_unittest.cc b/crypto/random_unittest.cc
index 00d4b2b..caee512 100644
--- a/crypto/random_unittest.cc
+++ b/crypto/random_unittest.cc
@@ -4,6 +4,8 @@
#include "crypto/random.h"
+#include <stddef.h>
+
#include "base/strings/string_util.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/crypto/rsa_private_key.cc b/crypto/rsa_private_key.cc
index 92c4f70..c546c91 100644
--- a/crypto/rsa_private_key.cc
+++ b/crypto/rsa_private_key.cc
@@ -4,6 +4,9 @@
#include "crypto/rsa_private_key.h"
+#include <stddef.h>
+#include <stdint.h>
+
#include <algorithm>
#include "base/logging.h"
@@ -43,21 +46,20 @@ namespace {
namespace crypto {
-const uint8 PrivateKeyInfoCodec::kRsaAlgorithmIdentifier[] = {
- 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01,
- 0x05, 0x00
-};
+const uint8_t PrivateKeyInfoCodec::kRsaAlgorithmIdentifier[] = {
+ 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86,
+ 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00};
PrivateKeyInfoCodec::PrivateKeyInfoCodec(bool big_endian)
: big_endian_(big_endian) {}
PrivateKeyInfoCodec::~PrivateKeyInfoCodec() {}
-bool PrivateKeyInfoCodec::Export(std::vector<uint8>* output) {
- std::list<uint8> content;
+bool PrivateKeyInfoCodec::Export(std::vector<uint8_t>* output) {
+ std::list<uint8_t> content;
// Version (always zero)
- uint8 version = 0;
+ uint8_t version = 0;
PrependInteger(coefficient_, &content);
PrependInteger(exponent2_, &content);
@@ -85,14 +87,14 @@ bool PrivateKeyInfoCodec::Export(std::vector<uint8>* output) {
return true;
}
-bool PrivateKeyInfoCodec::ExportPublicKeyInfo(std::vector<uint8>* output) {
+bool PrivateKeyInfoCodec::ExportPublicKeyInfo(std::vector<uint8_t>* output) {
// Create a sequence with the modulus (n) and public exponent (e).
- std::vector<uint8> bit_string;
+ std::vector<uint8_t> bit_string;
if (!ExportPublicKey(&bit_string))
return false;
// Add the sequence as the contents of a bit string.
- std::list<uint8> content;
+ std::list<uint8_t> content;
PrependBitString(&bit_string[0], static_cast<int>(bit_string.size()),
&content);
@@ -110,9 +112,9 @@ bool PrivateKeyInfoCodec::ExportPublicKeyInfo(std::vector<uint8>* output) {
return true;
}
-bool PrivateKeyInfoCodec::ExportPublicKey(std::vector<uint8>* output) {
+bool PrivateKeyInfoCodec::ExportPublicKey(std::vector<uint8_t>* output) {
// Create a sequence with the modulus (n) and public exponent (e).
- std::list<uint8> content;
+ std::list<uint8_t> content;
PrependInteger(&public_exponent_[0],
static_cast<int>(public_exponent_.size()),
&content);
@@ -126,15 +128,15 @@ bool PrivateKeyInfoCodec::ExportPublicKey(std::vector<uint8>* output) {
return true;
}
-bool PrivateKeyInfoCodec::Import(const std::vector<uint8>& input) {
+bool PrivateKeyInfoCodec::Import(const std::vector<uint8_t>& input) {
if (input.empty()) {
return false;
}
// Parse the private key info up to the public key values, ignoring
// the subsequent private key values.
- uint8* src = const_cast<uint8*>(&input.front());
- uint8* end = src + input.size();
+ uint8_t* src = const_cast<uint8_t*>(&input.front());
+ uint8_t* end = src + input.size();
if (!ReadSequence(&src, end) ||
!ReadVersion(&src, end) ||
!ReadAlgorithmIdentifier(&src, end) ||
@@ -163,25 +165,25 @@ bool PrivateKeyInfoCodec::Import(const std::vector<uint8>& input) {
return true;
}
-void PrivateKeyInfoCodec::PrependInteger(const std::vector<uint8>& in,
- std::list<uint8>* out) {
- uint8* ptr = const_cast<uint8*>(&in.front());
+void PrivateKeyInfoCodec::PrependInteger(const std::vector<uint8_t>& in,
+ std::list<uint8_t>* out) {
+ uint8_t* ptr = const_cast<uint8_t*>(&in.front());
PrependIntegerImpl(ptr, in.size(), out, big_endian_);
}
// Helper to prepend an ASN.1 integer.
-void PrivateKeyInfoCodec::PrependInteger(uint8* val,
+void PrivateKeyInfoCodec::PrependInteger(uint8_t* val,
int num_bytes,
- std::list<uint8>* data) {
+ std::list<uint8_t>* data) {
PrependIntegerImpl(val, num_bytes, data, big_endian_);
}
-void PrivateKeyInfoCodec::PrependIntegerImpl(uint8* val,
+void PrivateKeyInfoCodec::PrependIntegerImpl(uint8_t* val,
int num_bytes,
- std::list<uint8>* data,
+ std::list<uint8_t>* data,
bool big_endian) {
// Reverse input if little-endian.
- std::vector<uint8> tmp;
+ std::vector<uint8_t> tmp;
if (!big_endian) {
tmp.assign(val, val + num_bytes);
std::reverse(tmp.begin(), tmp.end());
@@ -201,7 +203,7 @@ void PrivateKeyInfoCodec::PrependIntegerImpl(uint8* val,
// (the most significant bit) would otherwise be set and make the number
// negative, ASN.1 requires a leading null byte to force the integer to be
// positive.
- uint8 front = data->front();
+ uint8_t front = data->front();
if ((front & 0x80) != 0) {
data->push_front(0x00);
num_bytes++;
@@ -210,17 +212,18 @@ void PrivateKeyInfoCodec::PrependIntegerImpl(uint8* val,
PrependTypeHeaderAndLength(kIntegerTag, num_bytes, data);
}
-bool PrivateKeyInfoCodec::ReadInteger(uint8** pos,
- uint8* end,
- std::vector<uint8>* out) {
+bool PrivateKeyInfoCodec::ReadInteger(uint8_t** pos,
+ uint8_t* end,
+ std::vector<uint8_t>* out) {
return ReadIntegerImpl(pos, end, out, big_endian_);
}
-bool PrivateKeyInfoCodec::ReadIntegerWithExpectedSize(uint8** pos,
- uint8* end,
- size_t expected_size,
- std::vector<uint8>* out) {
- std::vector<uint8> temp;
+bool PrivateKeyInfoCodec::ReadIntegerWithExpectedSize(
+ uint8_t** pos,
+ uint8_t* end,
+ size_t expected_size,
+ std::vector<uint8_t>* out) {
+ std::vector<uint8_t> temp;
if (!ReadIntegerImpl(pos, end, &temp, true)) // Big-Endian
return false;
@@ -243,11 +246,11 @@ bool PrivateKeyInfoCodec::ReadIntegerWithExpectedSize(uint8** pos,
return true;
}
-bool PrivateKeyInfoCodec::ReadIntegerImpl(uint8** pos,
- uint8* end,
- std::vector<uint8>* out,
+bool PrivateKeyInfoCodec::ReadIntegerImpl(uint8_t** pos,
+ uint8_t* end,
+ std::vector<uint8_t>* out,
bool big_endian) {
- uint32 length = 0;
+ uint32_t length = 0;
if (!ReadTypeHeaderAndLength(pos, end, kIntegerTag, &length) || !length)
return false;
@@ -268,25 +271,25 @@ bool PrivateKeyInfoCodec::ReadIntegerImpl(uint8** pos,
return true;
}
-void PrivateKeyInfoCodec::PrependBytes(uint8* val,
+void PrivateKeyInfoCodec::PrependBytes(uint8_t* val,
int start,
int num_bytes,
- std::list<uint8>* data) {
+ std::list<uint8_t>* data) {
while (num_bytes > 0) {
--num_bytes;
data->push_front(val[start + num_bytes]);
}
}
-void PrivateKeyInfoCodec::PrependLength(size_t size, std::list<uint8>* data) {
+void PrivateKeyInfoCodec::PrependLength(size_t size, std::list<uint8_t>* data) {
// The high bit is used to indicate whether additional octets are needed to
// represent the length.
if (size < 0x80) {
- data->push_front(static_cast<uint8>(size));
+ data->push_front(static_cast<uint8_t>(size));
} else {
- uint8 num_bytes = 0;
+ uint8_t num_bytes = 0;
while (size > 0) {
- data->push_front(static_cast<uint8>(size & 0xFF));
+ data->push_front(static_cast<uint8_t>(size & 0xFF));
size >>= 8;
num_bytes++;
}
@@ -295,16 +298,17 @@ void PrivateKeyInfoCodec::PrependLength(size_t size, std::list<uint8>* data) {
}
}
-void PrivateKeyInfoCodec::PrependTypeHeaderAndLength(uint8 type,
- uint32 length,
- std::list<uint8>* output) {
+void PrivateKeyInfoCodec::PrependTypeHeaderAndLength(
+ uint8_t type,
+ uint32_t length,
+ std::list<uint8_t>* output) {
PrependLength(length, output);
output->push_front(type);
}
-void PrivateKeyInfoCodec::PrependBitString(uint8* val,
+void PrivateKeyInfoCodec::PrependBitString(uint8_t* val,
int num_bytes,
- std::list<uint8>* output) {
+ std::list<uint8_t>* output) {
// Start with the data.
PrependBytes(val, 0, num_bytes, output);
// Zero unused bits.
@@ -312,10 +316,12 @@ void PrivateKeyInfoCodec::PrependBitString(uint8* val,
// Add the length.
PrependLength(num_bytes + 1, output);
// Finally, add the bit string tag.
- output->push_front((uint8) kBitStringTag);
+ output->push_front((uint8_t)kBitStringTag);
}
-bool PrivateKeyInfoCodec::ReadLength(uint8** pos, uint8* end, uint32* result) {
+bool PrivateKeyInfoCodec::ReadLength(uint8_t** pos,
+ uint8_t* end,
+ uint32_t* result) {
READ_ASSERT(*pos < end);
int length = 0;
@@ -343,10 +349,10 @@ bool PrivateKeyInfoCodec::ReadLength(uint8** pos, uint8* end, uint32* result) {
return true;
}
-bool PrivateKeyInfoCodec::ReadTypeHeaderAndLength(uint8** pos,
- uint8* end,
- uint8 expected_tag,
- uint32* length) {
+bool PrivateKeyInfoCodec::ReadTypeHeaderAndLength(uint8_t** pos,
+ uint8_t* end,
+ uint8_t expected_tag,
+ uint32_t* length) {
READ_ASSERT(*pos < end);
READ_ASSERT(**pos == expected_tag);
(*pos)++;
@@ -354,11 +360,11 @@ bool PrivateKeyInfoCodec::ReadTypeHeaderAndLength(uint8** pos,
return ReadLength(pos, end, length);
}
-bool PrivateKeyInfoCodec::ReadSequence(uint8** pos, uint8* end) {
+bool PrivateKeyInfoCodec::ReadSequence(uint8_t** pos, uint8_t* end) {
return ReadTypeHeaderAndLength(pos, end, kSequenceTag, NULL);
}
-bool PrivateKeyInfoCodec::ReadAlgorithmIdentifier(uint8** pos, uint8* end) {
+bool PrivateKeyInfoCodec::ReadAlgorithmIdentifier(uint8_t** pos, uint8_t* end) {
READ_ASSERT(*pos + sizeof(kRsaAlgorithmIdentifier) < end);
READ_ASSERT(memcmp(*pos, kRsaAlgorithmIdentifier,
sizeof(kRsaAlgorithmIdentifier)) == 0);
@@ -366,13 +372,13 @@ bool PrivateKeyInfoCodec::ReadAlgorithmIdentifier(uint8** pos, uint8* end) {
return true;
}
-bool PrivateKeyInfoCodec::ReadVersion(uint8** pos, uint8* end) {
- uint32 length = 0;
+bool PrivateKeyInfoCodec::ReadVersion(uint8_t** pos, uint8_t* end) {
+ uint32_t length = 0;
if (!ReadTypeHeaderAndLength(pos, end, kIntegerTag, &length))
return false;
// The version should be zero.
- for (uint32 i = 0; i < length; ++i) {
+ for (uint32_t i = 0; i < length; ++i) {
READ_ASSERT(**pos == 0x00);
(*pos)++;
}
diff --git a/crypto/rsa_private_key.h b/crypto/rsa_private_key.h
index fdcb392..9703334 100644
--- a/crypto/rsa_private_key.h
+++ b/crypto/rsa_private_key.h
@@ -5,10 +5,13 @@
#ifndef CRYPTO_RSA_PRIVATE_KEY_H_
#define CRYPTO_RSA_PRIVATE_KEY_H_
+#include <stddef.h>
+#include <stdint.h>
+
#include <list>
#include <vector>
-#include "base/basictypes.h"
+#include "base/macros.h"
#include "build/build_config.h"
#include "crypto/crypto_export.h"
@@ -30,14 +33,14 @@ namespace crypto {
class PrivateKeyInfoCodec {
public:
// ASN.1 encoding of the AlgorithmIdentifier from PKCS #8.
- static const uint8 kRsaAlgorithmIdentifier[];
+ static const uint8_t kRsaAlgorithmIdentifier[];
// ASN.1 tags for some types we use.
- static const uint8 kBitStringTag = 0x03;
- static const uint8 kIntegerTag = 0x02;
- static const uint8 kNullTag = 0x05;
- static const uint8 kOctetStringTag = 0x04;
- static const uint8 kSequenceTag = 0x30;
+ static const uint8_t kBitStringTag = 0x03;
+ static const uint8_t kIntegerTag = 0x02;
+ static const uint8_t kNullTag = 0x05;
+ static const uint8_t kOctetStringTag = 0x04;
+ static const uint8_t kSequenceTag = 0x30;
// |big_endian| here specifies the byte-significance of the integer components
// that will be parsed & serialized (modulus(), etc...) during Import(),
@@ -49,111 +52,113 @@ class PrivateKeyInfoCodec {
// Exports the contents of the integer components to the ASN.1 DER encoding
// of the PrivateKeyInfo structure to |output|.
- bool Export(std::vector<uint8>* output);
+ bool Export(std::vector<uint8_t>* output);
// Exports the contents of the integer components to the ASN.1 DER encoding
// of the PublicKeyInfo structure to |output|.
- bool ExportPublicKeyInfo(std::vector<uint8>* output);
+ bool ExportPublicKeyInfo(std::vector<uint8_t>* output);
// Exports the contents of the integer components to the ASN.1 DER encoding
// of the RSAPublicKey structure to |output|.
- bool ExportPublicKey(std::vector<uint8>* output);
+ bool ExportPublicKey(std::vector<uint8_t>* output);
// Parses the ASN.1 DER encoding of the PrivateKeyInfo structure in |input|
// and populates the integer components with |big_endian_| byte-significance.
// IMPORTANT NOTE: This is currently *not* security-approved for importing
// keys from unstrusted sources.
- bool Import(const std::vector<uint8>& input);
+ bool Import(const std::vector<uint8_t>& input);
// Accessors to the contents of the integer components of the PrivateKeyInfo
// structure.
- std::vector<uint8>* modulus() { return &modulus_; }
- std::vector<uint8>* public_exponent() { return &public_exponent_; }
- std::vector<uint8>* private_exponent() { return &private_exponent_; }
- std::vector<uint8>* prime1() { return &prime1_; }
- std::vector<uint8>* prime2() { return &prime2_; }
- std::vector<uint8>* exponent1() { return &exponent1_; }
- std::vector<uint8>* exponent2() { return &exponent2_; }
- std::vector<uint8>* coefficient() { return &coefficient_; }
+ std::vector<uint8_t>* modulus() { return &modulus_; }
+ std::vector<uint8_t>* public_exponent() { return &public_exponent_; }
+ std::vector<uint8_t>* private_exponent() { return &private_exponent_; }
+ std::vector<uint8_t>* prime1() { return &prime1_; }
+ std::vector<uint8_t>* prime2() { return &prime2_; }
+ std::vector<uint8_t>* exponent1() { return &exponent1_; }
+ std::vector<uint8_t>* exponent2() { return &exponent2_; }
+ std::vector<uint8_t>* coefficient() { return &coefficient_; }
private:
// Utility wrappers for PrependIntegerImpl that use the class's |big_endian_|
// value.
- void PrependInteger(const std::vector<uint8>& in, std::list<uint8>* out);
- void PrependInteger(uint8* val, int num_bytes, std::list<uint8>* data);
+ void PrependInteger(const std::vector<uint8_t>& in, std::list<uint8_t>* out);
+ void PrependInteger(uint8_t* val, int num_bytes, std::list<uint8_t>* data);
// Prepends the integer stored in |val| - |val + num_bytes| with |big_endian|
// byte-significance into |data| as an ASN.1 integer.
- void PrependIntegerImpl(uint8* val,
+ void PrependIntegerImpl(uint8_t* val,
int num_bytes,
- std::list<uint8>* data,
+ std::list<uint8_t>* data,
bool big_endian);
// Utility wrappers for ReadIntegerImpl that use the class's |big_endian_|
// value.
- bool ReadInteger(uint8** pos, uint8* end, std::vector<uint8>* out);
- bool ReadIntegerWithExpectedSize(uint8** pos,
- uint8* end,
+ bool ReadInteger(uint8_t** pos, uint8_t* end, std::vector<uint8_t>* out);
+ bool ReadIntegerWithExpectedSize(uint8_t** pos,
+ uint8_t* end,
size_t expected_size,
- std::vector<uint8>* out);
+ std::vector<uint8_t>* out);
// Reads an ASN.1 integer from |pos|, and stores the result into |out| with
// |big_endian| byte-significance.
- bool ReadIntegerImpl(uint8** pos,
- uint8* end,
- std::vector<uint8>* out,
+ bool ReadIntegerImpl(uint8_t** pos,
+ uint8_t* end,
+ std::vector<uint8_t>* out,
bool big_endian);
// Prepends the integer stored in |val|, starting a index |start|, for
// |num_bytes| bytes onto |data|.
- void PrependBytes(uint8* val,
+ void PrependBytes(uint8_t* val,
int start,
int num_bytes,
- std::list<uint8>* data);
+ std::list<uint8_t>* data);
// Helper to prepend an ASN.1 length field.
- void PrependLength(size_t size, std::list<uint8>* data);
+ void PrependLength(size_t size, std::list<uint8_t>* data);
// Helper to prepend an ASN.1 type header.
- void PrependTypeHeaderAndLength(uint8 type,
- uint32 length,
- std::list<uint8>* output);
+ void PrependTypeHeaderAndLength(uint8_t type,
+ uint32_t length,
+ std::list<uint8_t>* output);
// Helper to prepend an ASN.1 bit string
- void PrependBitString(uint8* val, int num_bytes, std::list<uint8>* output);
+ void PrependBitString(uint8_t* val,
+ int num_bytes,
+ std::list<uint8_t>* output);
// Read an ASN.1 length field. This also checks that the length does not
// extend beyond |end|.
- bool ReadLength(uint8** pos, uint8* end, uint32* result);
+ bool ReadLength(uint8_t** pos, uint8_t* end, uint32_t* result);
// Read an ASN.1 type header and its length.
- bool ReadTypeHeaderAndLength(uint8** pos,
- uint8* end,
- uint8 expected_tag,
- uint32* length);
+ bool ReadTypeHeaderAndLength(uint8_t** pos,
+ uint8_t* end,
+ uint8_t expected_tag,
+ uint32_t* length);
// Read an ASN.1 sequence declaration. This consumes the type header and
// length field, but not the contents of the sequence.
- bool ReadSequence(uint8** pos, uint8* end);
+ bool ReadSequence(uint8_t** pos, uint8_t* end);
// Read the RSA AlgorithmIdentifier.
- bool ReadAlgorithmIdentifier(uint8** pos, uint8* end);
+ bool ReadAlgorithmIdentifier(uint8_t** pos, uint8_t* end);
// Read one of the two version fields in PrivateKeyInfo.
- bool ReadVersion(uint8** pos, uint8* end);
+ bool ReadVersion(uint8_t** pos, uint8_t* end);
// The byte-significance of the stored components (modulus, etc..).
bool big_endian_;
// Component integers of the PrivateKeyInfo
- std::vector<uint8> modulus_;
- std::vector<uint8> public_exponent_;
- std::vector<uint8> private_exponent_;
- std::vector<uint8> prime1_;
- std::vector<uint8> prime2_;
- std::vector<uint8> exponent1_;
- std::vector<uint8> exponent2_;
- std::vector<uint8> coefficient_;
+ std::vector<uint8_t> modulus_;
+ std::vector<uint8_t> public_exponent_;
+ std::vector<uint8_t> private_exponent_;
+ std::vector<uint8_t> prime1_;
+ std::vector<uint8_t> prime2_;
+ std::vector<uint8_t> exponent1_;
+ std::vector<uint8_t> exponent2_;
+ std::vector<uint8_t> coefficient_;
DISALLOW_COPY_AND_ASSIGN(PrivateKeyInfoCodec);
};
@@ -166,13 +171,13 @@ class CRYPTO_EXPORT RSAPrivateKey {
~RSAPrivateKey();
// Create a new random instance. Can return NULL if initialization fails.
- static RSAPrivateKey* Create(uint16 num_bits);
+ static RSAPrivateKey* Create(uint16_t num_bits);
// Create a new instance by importing an existing private key. The format is
// an ASN.1-encoded PrivateKeyInfo block from PKCS #8. This can return NULL if
// initialization fails.
static RSAPrivateKey* CreateFromPrivateKeyInfo(
- const std::vector<uint8>& input);
+ const std::vector<uint8_t>& input);
#if defined(USE_OPENSSL)
// Create a new instance from an existing EVP_PKEY, taking a
@@ -196,10 +201,10 @@ class CRYPTO_EXPORT RSAPrivateKey {
RSAPrivateKey* Copy() const;
// Exports the private key to a PKCS #1 PrivateKey block.
- bool ExportPrivateKey(std::vector<uint8>* output) const;
+ bool ExportPrivateKey(std::vector<uint8_t>* output) const;
// Exports the public key to an X509 SubjectPublicKeyInfo block.
- bool ExportPublicKey(std::vector<uint8>* output) const;
+ bool ExportPublicKey(std::vector<uint8_t>* output) const;
private:
// Constructor is private. Use one of the Create*() methods above instead.
diff --git a/crypto/rsa_private_key_nss.cc b/crypto/rsa_private_key_nss.cc
index 88e55fa..349b7ea 100644
--- a/crypto/rsa_private_key_nss.cc
+++ b/crypto/rsa_private_key_nss.cc
@@ -7,6 +7,7 @@
#include <cryptohi.h>
#include <keyhi.h>
#include <pk11pub.h>
+#include <stdint.h>
#include <list>
@@ -23,7 +24,7 @@ namespace {
static bool ReadAttribute(SECKEYPrivateKey* key,
CK_ATTRIBUTE_TYPE type,
- std::vector<uint8>* output) {
+ std::vector<uint8_t>* output) {
SECItem item;
SECStatus rv;
rv = PK11_ReadRawAttribute(PK11_TypePrivKey, key, type, &item);
@@ -49,7 +50,7 @@ RSAPrivateKey::~RSAPrivateKey() {
}
// static
-RSAPrivateKey* RSAPrivateKey::Create(uint16 num_bits) {
+RSAPrivateKey* RSAPrivateKey::Create(uint16_t num_bits) {
EnsureNSSInit();
ScopedPK11Slot slot(PK11_GetInternalSlot());
@@ -73,7 +74,7 @@ RSAPrivateKey* RSAPrivateKey::Create(uint16 num_bits) {
// static
RSAPrivateKey* RSAPrivateKey::CreateFromPrivateKeyInfo(
- const std::vector<uint8>& input) {
+ const std::vector<uint8_t>& input) {
EnsureNSSInit();
ScopedPK11Slot slot(PK11_GetInternalSlot());
@@ -111,7 +112,7 @@ RSAPrivateKey* RSAPrivateKey::Copy() const {
return copy;
}
-bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) const {
+bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8_t>* output) const {
PrivateKeyInfoCodec private_key_info(true);
// Manually read the component attributes of the private key and build up
@@ -133,7 +134,7 @@ bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) const {
return private_key_info.Export(output);
}
-bool RSAPrivateKey::ExportPublicKey(std::vector<uint8>* output) const {
+bool RSAPrivateKey::ExportPublicKey(std::vector<uint8_t>* output) const {
ScopedSECItem der_pubkey(SECKEY_EncodeDERSubjectPublicKeyInfo(public_key_));
if (!der_pubkey.get()) {
NOTREACHED();
diff --git a/crypto/rsa_private_key_openssl.cc b/crypto/rsa_private_key_openssl.cc
index 52a0a7a..f7fdd9d 100644
--- a/crypto/rsa_private_key_openssl.cc
+++ b/crypto/rsa_private_key_openssl.cc
@@ -9,6 +9,7 @@
#include <openssl/evp.h>
#include <openssl/pkcs12.h>
#include <openssl/rsa.h>
+#include <stdint.h>
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -30,7 +31,7 @@ using ExportFunction = int (*)(BIO*, EVP_PKEY*);
// Helper to export |key| into |output| via the specified ExportFunction.
bool ExportKey(EVP_PKEY* key,
ExportFunction export_fn,
- std::vector<uint8>* output) {
+ std::vector<uint8_t>* output) {
if (!key)
return false;
@@ -53,7 +54,7 @@ bool ExportKey(EVP_PKEY* key,
} // namespace
// static
-RSAPrivateKey* RSAPrivateKey::Create(uint16 num_bits) {
+RSAPrivateKey* RSAPrivateKey::Create(uint16_t num_bits) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
ScopedRSA rsa_key(RSA_new());
@@ -74,7 +75,7 @@ RSAPrivateKey* RSAPrivateKey::Create(uint16 num_bits) {
// static
RSAPrivateKey* RSAPrivateKey::CreateFromPrivateKeyInfo(
- const std::vector<uint8>& input) {
+ const std::vector<uint8_t>& input) {
if (input.empty())
return NULL;
@@ -127,11 +128,11 @@ RSAPrivateKey* RSAPrivateKey::Copy() const {
return copy.release();
}
-bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) const {
+bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8_t>* output) const {
return ExportKey(key_, i2d_PKCS8PrivateKeyInfo_bio, output);
}
-bool RSAPrivateKey::ExportPublicKey(std::vector<uint8>* output) const {
+bool RSAPrivateKey::ExportPublicKey(std::vector<uint8_t>* output) const {
return ExportKey(key_, i2d_PUBKEY_bio, output);
}
diff --git a/crypto/rsa_private_key_unittest.cc b/crypto/rsa_private_key_unittest.cc
index 9e7f6ff..1401e3d 100644
--- a/crypto/rsa_private_key_unittest.cc
+++ b/crypto/rsa_private_key_unittest.cc
@@ -4,93 +4,67 @@
#include "crypto/rsa_private_key.h"
+#include <stdint.h>
+
#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
-const uint8 kTestPrivateKeyInfo[] = {
- 0x30, 0x82, 0x02, 0x78, 0x02, 0x01, 0x00, 0x30,
- 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
- 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82,
- 0x02, 0x62, 0x30, 0x82, 0x02, 0x5e, 0x02, 0x01,
- 0x00, 0x02, 0x81, 0x81, 0x00, 0xb8, 0x7f, 0x2b,
- 0x20, 0xdc, 0x7c, 0x9b, 0x0c, 0xdc, 0x51, 0x61,
- 0x99, 0x0d, 0x36, 0x0f, 0xd4, 0x66, 0x88, 0x08,
- 0x55, 0x84, 0xd5, 0x3a, 0xbf, 0x2b, 0xa4, 0x64,
- 0x85, 0x7b, 0x0c, 0x04, 0x13, 0x3f, 0x8d, 0xf4,
- 0xbc, 0x38, 0x0d, 0x49, 0xfe, 0x6b, 0xc4, 0x5a,
- 0xb0, 0x40, 0x53, 0x3a, 0xd7, 0x66, 0x09, 0x0f,
- 0x9e, 0x36, 0x74, 0x30, 0xda, 0x8a, 0x31, 0x4f,
- 0x1f, 0x14, 0x50, 0xd7, 0xc7, 0x20, 0x94, 0x17,
- 0xde, 0x4e, 0xb9, 0x57, 0x5e, 0x7e, 0x0a, 0xe5,
- 0xb2, 0x65, 0x7a, 0x89, 0x4e, 0xb6, 0x47, 0xff,
- 0x1c, 0xbd, 0xb7, 0x38, 0x13, 0xaf, 0x47, 0x85,
- 0x84, 0x32, 0x33, 0xf3, 0x17, 0x49, 0xbf, 0xe9,
- 0x96, 0xd0, 0xd6, 0x14, 0x6f, 0x13, 0x8d, 0xc5,
- 0xfc, 0x2c, 0x72, 0xba, 0xac, 0xea, 0x7e, 0x18,
- 0x53, 0x56, 0xa6, 0x83, 0xa2, 0xce, 0x93, 0x93,
- 0xe7, 0x1f, 0x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2f, 0xf1,
- 0x75, 0x74, 0x0d, 0x5e, 0xb5, 0x11, 0x73, 0xb0,
- 0x0a, 0xaa, 0x86, 0x4c, 0x0d, 0xff, 0x7e, 0x1d,
- 0xb4, 0x14, 0xd4, 0x09, 0x91, 0x33, 0x5a, 0xfd,
- 0xa0, 0x58, 0x80, 0x9b, 0xbe, 0x78, 0x2e, 0x69,
- 0x82, 0x15, 0x7c, 0x72, 0xf0, 0x7b, 0x18, 0x39,
- 0xff, 0x6e, 0xeb, 0xc6, 0x86, 0xf5, 0xb4, 0xc7,
- 0x6f, 0x02, 0x41, 0x00, 0x8d, 0x1a, 0x37, 0x0f,
- 0x76, 0xc4, 0x82, 0xfa, 0x5c, 0xc3, 0x79, 0x35,
- 0x3e, 0x70, 0x8a, 0xbf, 0x27, 0x49, 0xb0, 0x99,
- 0x63, 0xcb, 0x77, 0x5f, 0xa8, 0x82, 0x65, 0xf6,
- 0x03, 0x52, 0x51, 0xf1, 0xae, 0x2e, 0x05, 0xb3,
- 0xc6, 0xa4, 0x92, 0xd1, 0xce, 0x6c, 0x72, 0xfb,
- 0x21, 0xb3, 0x02, 0x87, 0xe4, 0xfd, 0x61, 0xca,
- 0x00, 0x42, 0x19, 0xf0, 0xda, 0x5a, 0x53, 0xe3,
- 0xb1, 0xc5, 0x15, 0xf3
-};
+const uint8_t kTestPrivateKeyInfo[] = {
+ 0x30, 0x82, 0x02, 0x78, 0x02, 0x01, 0x00, 0x30, 0x0d, 0x06, 0x09, 0x2a,
+ 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82,
+ 0x02, 0x62, 0x30, 0x82, 0x02, 0x5e, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81,
+ 0x00, 0xb8, 0x7f, 0x2b, 0x20, 0xdc, 0x7c, 0x9b, 0x0c, 0xdc, 0x51, 0x61,
+ 0x99, 0x0d, 0x36, 0x0f, 0xd4, 0x66, 0x88, 0x08, 0x55, 0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, 0xb0, 0x99, 0x63, 0xcb, 0x77, 0x5f, 0xa8, 0x82, 0x65, 0xf6,
+ 0x03, 0x52, 0x51, 0xf1, 0xae, 0x2e, 0x05, 0xb3, 0xc6, 0xa4, 0x92, 0xd1,
+ 0xce, 0x6c, 0x72, 0xfb, 0x21, 0xb3, 0x02, 0x87, 0xe4, 0xfd, 0x61, 0xca,
+ 0x00, 0x42, 0x19, 0xf0, 0xda, 0x5a, 0x53, 0xe3, 0xb1, 0xc5, 0x15, 0xf3};
} // namespace
@@ -104,10 +78,10 @@ TEST(RSAPrivateKeyUnitTest, InitRandomTest) {
ASSERT_TRUE(keypair1.get());
ASSERT_TRUE(keypair2.get());
- std::vector<uint8> privkey1;
- std::vector<uint8> privkey2;
- std::vector<uint8> pubkey1;
- std::vector<uint8> pubkey2;
+ std::vector<uint8_t> privkey1;
+ std::vector<uint8_t> privkey2;
+ std::vector<uint8_t> pubkey1;
+ std::vector<uint8_t> pubkey2;
ASSERT_TRUE(keypair1->ExportPrivateKey(&privkey1));
ASSERT_TRUE(keypair2->ExportPrivateKey(&privkey2));
@@ -121,8 +95,8 @@ TEST(RSAPrivateKeyUnitTest, InitRandomTest) {
ASSERT_TRUE(keypair3.get());
ASSERT_TRUE(keypair4.get());
- std::vector<uint8> privkey3;
- std::vector<uint8> privkey4;
+ std::vector<uint8_t> privkey3;
+ std::vector<uint8_t> privkey4;
ASSERT_TRUE(keypair3->ExportPrivateKey(&privkey3));
ASSERT_TRUE(keypair4->ExportPrivateKey(&privkey4));
@@ -136,8 +110,8 @@ TEST(RSAPrivateKeyUnitTest, InitRandomTest) {
// Test Copy() method.
TEST(RSAPrivateKeyUnitTest, CopyTest) {
- std::vector<uint8> input(
- kTestPrivateKeyInfo, kTestPrivateKeyInfo + sizeof(kTestPrivateKeyInfo));
+ std::vector<uint8_t> input(kTestPrivateKeyInfo,
+ kTestPrivateKeyInfo + sizeof(kTestPrivateKeyInfo));
scoped_ptr<crypto::RSAPrivateKey> key(
crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(input));
@@ -145,7 +119,7 @@ TEST(RSAPrivateKeyUnitTest, CopyTest) {
scoped_ptr<crypto::RSAPrivateKey> key_copy(key->Copy());
ASSERT_TRUE(key_copy.get());
- std::vector<uint8> privkey_copy;
+ std::vector<uint8_t> privkey_copy;
ASSERT_TRUE(key_copy->ExportPrivateKey(&privkey_copy));
ASSERT_EQ(input, privkey_copy);
}
@@ -153,8 +127,8 @@ TEST(RSAPrivateKeyUnitTest, CopyTest) {
// Test that CreateFromPrivateKeyInfo fails if there is extra data after the RSA
// key.
TEST(RSAPrivateKeyUnitTest, ExtraData) {
- std::vector<uint8> input(
- kTestPrivateKeyInfo, kTestPrivateKeyInfo + sizeof(kTestPrivateKeyInfo));
+ std::vector<uint8_t> input(kTestPrivateKeyInfo,
+ kTestPrivateKeyInfo + sizeof(kTestPrivateKeyInfo));
input.push_back(0);
scoped_ptr<crypto::RSAPrivateKey> key(
@@ -166,7 +140,7 @@ TEST(RSAPrivateKeyUnitTest, ExtraData) {
TEST(RSAPrivateKeyUnitTest, NotRsaKey) {
// Defines a valid P-256 private key.
- const uint8 kTestEcPrivateKeyInfo[] = {
+ const uint8_t kTestEcPrivateKeyInfo[] = {
0x30, 0x81, 0x87, 0x02, 0x01, 0x00, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86,
0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D,
0x03, 0x01, 0x07, 0x04, 0x6D, 0x30, 0x6B, 0x02, 0x01, 0x01, 0x04, 0x20,
@@ -178,10 +152,9 @@ TEST(RSAPrivateKeyUnitTest, NotRsaKey) {
0x8D, 0xC5, 0xAD, 0xA8, 0xE9, 0xA9, 0xDD, 0x7C, 0xB3, 0xC7, 0x0D, 0xF4,
0x48, 0x98, 0x6E, 0x51, 0xBD, 0xE5, 0xD1, 0x57, 0x6F, 0x99, 0x90, 0x1F,
0x9C, 0x2C, 0x6A, 0x80, 0x6A, 0x47, 0xFD, 0x90, 0x76, 0x43, 0xA7, 0x2B,
- 0x83, 0x55, 0x97, 0xEF, 0xC8, 0xC6
- };
+ 0x83, 0x55, 0x97, 0xEF, 0xC8, 0xC6};
- std::vector<uint8> input(
+ std::vector<uint8_t> input(
kTestEcPrivateKeyInfo,
kTestEcPrivateKeyInfo + sizeof(kTestEcPrivateKeyInfo));
@@ -195,38 +168,30 @@ TEST(RSAPrivateKeyUnitTest, NotRsaKey) {
// Verify that generated public keys look good. This test data was generated
// with the openssl command line tool.
TEST(RSAPrivateKeyUnitTest, PublicKeyTest) {
- const uint8 expected_public_key_info[] = {
- 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a,
- 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01,
- 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81,
- 0x89, 0x02, 0x81, 0x81, 0x00, 0xb8, 0x7f, 0x2b,
- 0x20, 0xdc, 0x7c, 0x9b, 0x0c, 0xdc, 0x51, 0x61,
- 0x99, 0x0d, 0x36, 0x0f, 0xd4, 0x66, 0x88, 0x08,
- 0x55, 0x84, 0xd5, 0x3a, 0xbf, 0x2b, 0xa4, 0x64,
- 0x85, 0x7b, 0x0c, 0x04, 0x13, 0x3f, 0x8d, 0xf4,
- 0xbc, 0x38, 0x0d, 0x49, 0xfe, 0x6b, 0xc4, 0x5a,
- 0xb0, 0x40, 0x53, 0x3a, 0xd7, 0x66, 0x09, 0x0f,
- 0x9e, 0x36, 0x74, 0x30, 0xda, 0x8a, 0x31, 0x4f,
- 0x1f, 0x14, 0x50, 0xd7, 0xc7, 0x20, 0x94, 0x17,
- 0xde, 0x4e, 0xb9, 0x57, 0x5e, 0x7e, 0x0a, 0xe5,
- 0xb2, 0x65, 0x7a, 0x89, 0x4e, 0xb6, 0x47, 0xff,
- 0x1c, 0xbd, 0xb7, 0x38, 0x13, 0xaf, 0x47, 0x85,
- 0x84, 0x32, 0x33, 0xf3, 0x17, 0x49, 0xbf, 0xe9,
- 0x96, 0xd0, 0xd6, 0x14, 0x6f, 0x13, 0x8d, 0xc5,
- 0xfc, 0x2c, 0x72, 0xba, 0xac, 0xea, 0x7e, 0x18,
- 0x53, 0x56, 0xa6, 0x83, 0xa2, 0xce, 0x93, 0x93,
- 0xe7, 0x1f, 0x0f, 0xe6, 0x0f, 0x02, 0x03, 0x01,
- 0x00, 0x01
- };
-
- std::vector<uint8> input(
- kTestPrivateKeyInfo, kTestPrivateKeyInfo + sizeof(kTestPrivateKeyInfo));
+ const uint8_t expected_public_key_info[] = {
+ 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
+ 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81,
+ 0x89, 0x02, 0x81, 0x81, 0x00, 0xb8, 0x7f, 0x2b, 0x20, 0xdc, 0x7c, 0x9b,
+ 0x0c, 0xdc, 0x51, 0x61, 0x99, 0x0d, 0x36, 0x0f, 0xd4, 0x66, 0x88, 0x08,
+ 0x55, 0x84, 0xd5, 0x3a, 0xbf, 0x2b, 0xa4, 0x64, 0x85, 0x7b, 0x0c, 0x04,
+ 0x13, 0x3f, 0x8d, 0xf4, 0xbc, 0x38, 0x0d, 0x49, 0xfe, 0x6b, 0xc4, 0x5a,
+ 0xb0, 0x40, 0x53, 0x3a, 0xd7, 0x66, 0x09, 0x0f, 0x9e, 0x36, 0x74, 0x30,
+ 0xda, 0x8a, 0x31, 0x4f, 0x1f, 0x14, 0x50, 0xd7, 0xc7, 0x20, 0x94, 0x17,
+ 0xde, 0x4e, 0xb9, 0x57, 0x5e, 0x7e, 0x0a, 0xe5, 0xb2, 0x65, 0x7a, 0x89,
+ 0x4e, 0xb6, 0x47, 0xff, 0x1c, 0xbd, 0xb7, 0x38, 0x13, 0xaf, 0x47, 0x85,
+ 0x84, 0x32, 0x33, 0xf3, 0x17, 0x49, 0xbf, 0xe9, 0x96, 0xd0, 0xd6, 0x14,
+ 0x6f, 0x13, 0x8d, 0xc5, 0xfc, 0x2c, 0x72, 0xba, 0xac, 0xea, 0x7e, 0x18,
+ 0x53, 0x56, 0xa6, 0x83, 0xa2, 0xce, 0x93, 0x93, 0xe7, 0x1f, 0x0f, 0xe6,
+ 0x0f, 0x02, 0x03, 0x01, 0x00, 0x01};
+
+ std::vector<uint8_t> input(kTestPrivateKeyInfo,
+ kTestPrivateKeyInfo + sizeof(kTestPrivateKeyInfo));
scoped_ptr<crypto::RSAPrivateKey> key(
crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(input));
ASSERT_TRUE(key.get());
- std::vector<uint8> output;
+ std::vector<uint8_t> output;
ASSERT_TRUE(key->ExportPublicKey(&output));
ASSERT_TRUE(
@@ -248,174 +213,118 @@ TEST(RSAPrivateKeyUnitTest, PublicKeyTest) {
//
// This test case verifies these two failures modes don't occur.
TEST(RSAPrivateKeyUnitTest, ShortIntegers) {
- const uint8 short_integer_with_high_bit[] = {
- 0x30, 0x82, 0x02, 0x77, 0x02, 0x01, 0x00, 0x30,
- 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
- 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82,
- 0x02, 0x61, 0x30, 0x82, 0x02, 0x5d, 0x02, 0x01,
- 0x00, 0x02, 0x81, 0x81, 0x00, 0x92, 0x59, 0x32,
- 0x7d, 0x8e, 0xaf, 0x2e, 0xd5, 0xb2, 0x5c, 0x67,
- 0xc8, 0x7d, 0x48, 0xb7, 0x84, 0x12, 0xd0, 0x76,
- 0xda, 0xe1, 0xa3, 0x1e, 0x40, 0x01, 0x14, 0x5c,
- 0xef, 0x26, 0x6e, 0x28, 0xa2, 0xf7, 0xa5, 0xb4,
- 0x02, 0x37, 0xd0, 0x53, 0x10, 0xcb, 0x7c, 0x6a,
- 0xf4, 0x53, 0x9f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b, 0xa2,
- 0x6b, 0x2d, 0x21, 0xa4, 0x65, 0xe9, 0xfa, 0x8c,
- 0x30, 0x2a, 0x89, 0xce, 0xd0, 0xa7, 0x67, 0xd8,
- 0x45, 0x84, 0xb0
- };
-
- const uint8 short_integer_without_high_bit[] = {
- 0x30, 0x82, 0x02, 0x76, 0x02, 0x01, 0x00, 0x30,
- 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
- 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82,
- 0x02, 0x60, 0x30, 0x82, 0x02, 0x5c, 0x02, 0x01,
- 0x00, 0x02, 0x81, 0x81, 0x00, 0xc3, 0x9e, 0x8d,
- 0xc4, 0x6d, 0x38, 0xe8, 0x0e, 0x9f, 0x84, 0x03,
- 0x40, 0x8e, 0x81, 0x2e, 0x56, 0x67, 0x78, 0x11,
- 0x85, 0x27, 0x81, 0x52, 0xf2, 0x1b, 0x3e, 0x5b,
- 0xf8, 0xab, 0xfc, 0xaf, 0xca, 0x5c, 0x26, 0xd5,
- 0xfa, 0xd4, 0x55, 0x50, 0x38, 0xb9, 0x9d, 0x89,
- 0x92, 0x7e, 0x34, 0xcf, 0x37, 0x82, 0x48, 0x2d,
- 0xaa, 0xc4, 0x6a, 0x0e, 0x93, 0xea, 0xad, 0x8a,
- 0x33, 0xf0, 0x42, 0x23, 0xe0, 0x4c, 0x98, 0xbf,
- 0x01, 0x00, 0x1b, 0xfe, 0x06, 0x15, 0xc6, 0xe3,
- 0x80, 0x79, 0x6d, 0xfe, 0x48, 0xcd, 0x40, 0xbb,
- 0xf9, 0x58, 0xe6, 0xbf, 0xd5, 0x4c, 0x29, 0x48,
- 0x53, 0x78, 0x06, 0x03, 0x0d, 0x59, 0xf5, 0x20,
- 0xe0, 0xe6, 0x8c, 0xb2, 0xf5, 0xd8, 0x61, 0x52,
- 0x7e, 0x40, 0x83, 0xd7, 0x69, 0xae, 0xd7, 0x75,
- 0x02, 0x2d, 0x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, 0x91,
- 0x05, 0xc5, 0x3c, 0x9d, 0xcf, 0x8a, 0x60, 0xc7,
- 0x9b, 0x2b, 0xe5, 0xc6, 0xba, 0x1b, 0xfc, 0xf3,
- 0xd9, 0x54, 0x97, 0xe9, 0xc4, 0x00, 0x80, 0x90,
- 0x4a, 0xd2, 0x6a, 0xbc, 0x8b, 0x62, 0x22, 0x3c,
- 0x68, 0x0c, 0xda, 0xdb, 0xe3, 0xd2, 0x76, 0x8e,
- 0xff, 0x03, 0x12, 0x09, 0x2a, 0xac, 0x21, 0x44,
- 0xb7, 0x3e, 0x91, 0x9c, 0x09, 0xf6, 0xd7, 0x02,
- 0x41, 0x00, 0xc0, 0xa1, 0xbb, 0x70, 0xdc, 0xf8,
- 0xeb, 0x17, 0x61, 0xd4, 0x8c, 0x7c, 0x3b, 0x82,
- 0x91, 0x58, 0xff, 0xf9, 0x19, 0xac, 0x3a, 0x73,
- 0xa7, 0x20, 0xe5, 0x22, 0x02, 0xc4, 0xf6, 0xb9,
- 0xb9, 0x43, 0x53, 0x35, 0x88, 0xe1, 0x05, 0xb6,
- 0x43, 0x9b, 0x39, 0xc8, 0x04, 0x4d, 0x2b, 0x01,
- 0xf7, 0xe6, 0x1b, 0x8d, 0x7e, 0x89, 0xe3, 0x43,
- 0xd4, 0xf3, 0xab, 0x28, 0xd4, 0x5a, 0x1f, 0x20,
- 0xea, 0xbe
- };
-
- std::vector<uint8> input1;
- std::vector<uint8> input2;
+ const uint8_t short_integer_with_high_bit[] = {
+ 0x30, 0x82, 0x02, 0x77, 0x02, 0x01, 0x00, 0x30, 0x0d, 0x06, 0x09, 0x2a,
+ 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82,
+ 0x02, 0x61, 0x30, 0x82, 0x02, 0x5d, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81,
+ 0x00, 0x92, 0x59, 0x32, 0x7d, 0x8e, 0xaf, 0x2e, 0xd5, 0xb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xbb, 0x6a, 0x9b, 0xe6, 0x3a, 0x4d, 0xc1, 0xdb, 0xe5, 0x52, 0x38,
+ 0xf9, 0x59, 0x91, 0x2d, 0x90, 0x82, 0xe3, 0x31, 0x1b, 0x48, 0xb7, 0x42,
+ 0xfa, 0x1d, 0x83, 0xd5, 0x3d, 0x02, 0xc2, 0x12, 0x71, 0x10, 0x3a, 0xbd,
+ 0x92, 0x8f, 0x9b, 0xa2, 0x6b, 0x2d, 0x21, 0xa4, 0x65, 0xe9, 0xfa, 0x8c,
+ 0x30, 0x2a, 0x89, 0xce, 0xd0, 0xa7, 0x67, 0xd8, 0x45, 0x84, 0xb0};
+
+ const uint8_t short_integer_without_high_bit[] = {
+ 0x30, 0x82, 0x02, 0x76, 0x02, 0x01, 0x00, 0x30, 0x0d, 0x06, 0x09, 0x2a,
+ 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82,
+ 0x02, 0x60, 0x30, 0x82, 0x02, 0x5c, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81,
+ 0x00, 0xc3, 0x9e, 0x8d, 0xc4, 0x6d, 0x38, 0xe8, 0x0e, 0x9f, 0x84, 0x03,
+ 0x40, 0x8e, 0x81, 0x2e, 0x56, 0x67, 0x78, 0x11, 0x85, 0x27, 0x81, 0x52,
+ 0xf2, 0x1b, 0x3e, 0x5b, 0xf8, 0xab, 0xfc, 0xaf, 0xca, 0x5c, 0x26, 0xd5,
+ 0xfa, 0xd4, 0x55, 0x50, 0x38, 0xb9, 0x9d, 0x89, 0x92, 0x7e, 0x34, 0xcf,
+ 0x37, 0x82, 0x48, 0x2d, 0xaa, 0xc4, 0x6a, 0x0e, 0x93, 0xea, 0xad, 0x8a,
+ 0x33, 0xf0, 0x42, 0x23, 0xe0, 0x4c, 0x98, 0xbf, 0x01, 0x00, 0x1b, 0xfe,
+ 0x06, 0x15, 0xc6, 0xe3, 0x80, 0x79, 0x6d, 0xfe, 0x48, 0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x00, 0x63, 0x5e, 0x76, 0xcb, 0x3f, 0x02, 0x19,
+ 0xe6, 0xda, 0xfa, 0x01, 0x05, 0xd7, 0x65, 0x37, 0x0b, 0x60, 0x7f, 0x94,
+ 0x2a, 0x80, 0x8d, 0x22, 0x81, 0x68, 0x65, 0x63, 0x02, 0x41, 0x00, 0xc2,
+ 0xd4, 0x18, 0xde, 0x47, 0x9e, 0xfb, 0x8d, 0x91, 0x05, 0xc5, 0x3c, 0x9d,
+ 0xcf, 0x8a, 0x60, 0xc7, 0x9b, 0x2b, 0xe5, 0xc6, 0xba, 0x1b, 0xfc, 0xf3,
+ 0xd9, 0x54, 0x97, 0xe9, 0xc4, 0x00, 0x80, 0x90, 0x4a, 0xd2, 0x6a, 0xbc,
+ 0x8b, 0x62, 0x22, 0x3c, 0x68, 0x0c, 0xda, 0xdb, 0xe3, 0xd2, 0x76, 0x8e,
+ 0xff, 0x03, 0x12, 0x09, 0x2a, 0xac, 0x21, 0x44, 0xb7, 0x3e, 0x91, 0x9c,
+ 0x09, 0xf6, 0xd7, 0x02, 0x41, 0x00, 0xc0, 0xa1, 0xbb, 0x70, 0xdc, 0xf8,
+ 0xeb, 0x17, 0x61, 0xd4, 0x8c, 0x7c, 0x3b, 0x82, 0x91, 0x58, 0xff, 0xf9,
+ 0x19, 0xac, 0x3a, 0x73, 0xa7, 0x20, 0xe5, 0x22, 0x02, 0xc4, 0xf6, 0xb9,
+ 0xb9, 0x43, 0x53, 0x35, 0x88, 0xe1, 0x05, 0xb6, 0x43, 0x9b, 0x39, 0xc8,
+ 0x04, 0x4d, 0x2b, 0x01, 0xf7, 0xe6, 0x1b, 0x8d, 0x7e, 0x89, 0xe3, 0x43,
+ 0xd4, 0xf3, 0xab, 0x28, 0xd4, 0x5a, 0x1f, 0x20, 0xea, 0xbe};
+
+ std::vector<uint8_t> input1;
+ std::vector<uint8_t> input2;
input1.resize(sizeof(short_integer_with_high_bit));
input2.resize(sizeof(short_integer_without_high_bit));
@@ -432,8 +341,8 @@ TEST(RSAPrivateKeyUnitTest, ShortIntegers) {
ASSERT_TRUE(keypair1.get());
ASSERT_TRUE(keypair2.get());
- std::vector<uint8> output1;
- std::vector<uint8> output2;
+ std::vector<uint8_t> output1;
+ std::vector<uint8_t> output2;
ASSERT_TRUE(keypair1->ExportPrivateKey(&output1));
ASSERT_TRUE(keypair2->ExportPrivateKey(&output2));
@@ -454,13 +363,13 @@ TEST(RSAPrivateKeyUnitTest, CreateFromKeyTest) {
crypto::RSAPrivateKey::CreateFromKey(key_pair->key()));
ASSERT_TRUE(key_copy.get());
- std::vector<uint8> privkey;
- std::vector<uint8> pubkey;
+ std::vector<uint8_t> privkey;
+ std::vector<uint8_t> pubkey;
ASSERT_TRUE(key_pair->ExportPrivateKey(&privkey));
ASSERT_TRUE(key_pair->ExportPublicKey(&pubkey));
- std::vector<uint8> privkey_copy;
- std::vector<uint8> pubkey_copy;
+ std::vector<uint8_t> privkey_copy;
+ std::vector<uint8_t> pubkey_copy;
ASSERT_TRUE(key_copy->ExportPrivateKey(&privkey_copy));
ASSERT_TRUE(key_copy->ExportPublicKey(&pubkey_copy));
diff --git a/crypto/scoped_capi_types.h b/crypto/scoped_capi_types.h
index ac92e39..74e5765 100644
--- a/crypto/scoped_capi_types.h
+++ b/crypto/scoped_capi_types.h
@@ -10,6 +10,7 @@
#include <algorithm>
#include "base/logging.h"
+#include "base/macros.h"
#include "crypto/wincrypt_shim.h"
namespace crypto {
diff --git a/crypto/scoped_openssl_types.h b/crypto/scoped_openssl_types.h
index bdae6aa..9bc5d74 100644
--- a/crypto/scoped_openssl_types.h
+++ b/crypto/scoped_openssl_types.h
@@ -13,6 +13,7 @@
#include <openssl/evp.h>
#include <openssl/mem.h>
#include <openssl/rsa.h>
+#include <stdint.h>
#include "base/memory/scoped_ptr.h"
diff --git a/crypto/secure_hash.h b/crypto/secure_hash.h
index 23349b0..491a299a3 100644
--- a/crypto/secure_hash.h
+++ b/crypto/secure_hash.h
@@ -5,7 +5,9 @@
#ifndef CRYPTO_SECURE_HASH_H_
#define CRYPTO_SECURE_HASH_H_
-#include "base/basictypes.h"
+#include <stddef.h>
+
+#include "base/macros.h"
#include "crypto/crypto_export.h"
namespace base {
diff --git a/crypto/secure_hash_default.cc b/crypto/secure_hash_default.cc
index 739b402..cec6fb8 100644
--- a/crypto/secure_hash_default.cc
+++ b/crypto/secure_hash_default.cc
@@ -4,6 +4,8 @@
#include "crypto/secure_hash.h"
+#include <stddef.h>
+
#include "base/logging.h"
#include "base/pickle.h"
#include "crypto/third_party/nss/chromium-blapi.h"
diff --git a/crypto/secure_hash_openssl.cc b/crypto/secure_hash_openssl.cc
index 1033b8e..ec859ff 100644
--- a/crypto/secure_hash_openssl.cc
+++ b/crypto/secure_hash_openssl.cc
@@ -6,8 +6,8 @@
#include <openssl/mem.h>
#include <openssl/sha.h>
+#include <stddef.h>
-#include "base/basictypes.h"
#include "base/logging.h"
#include "base/pickle.h"
#include "crypto/openssl_util.h"
diff --git a/crypto/secure_hash_unittest.cc b/crypto/secure_hash_unittest.cc
index facf476..df0afa6 100644
--- a/crypto/secure_hash_unittest.cc
+++ b/crypto/secure_hash_unittest.cc
@@ -4,9 +4,11 @@
#include "crypto/secure_hash.h"
+#include <stddef.h>
+#include <stdint.h>
+
#include <string>
-#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/pickle.h"
#include "crypto/sha2.h"
@@ -24,7 +26,7 @@ TEST(SecureHashTest, TestUpdate) {
0x04, 0x6d, 0x39, 0xcc,
0xc7, 0x11, 0x2c, 0xd0 };
- uint8 output3[crypto::kSHA256Length];
+ uint8_t output3[crypto::kSHA256Length];
scoped_ptr<crypto::SecureHash> ctx(crypto::SecureHash::Create(
crypto::SecureHash::SHA256));
@@ -46,8 +48,8 @@ TEST(SecureHashTest, TestSerialization) {
std::string input4(10001, 'd'); // 'd' repeated 10001 times
std::string input5(10001, 'e'); // 'e' repeated 10001 times
- uint8 output1[crypto::kSHA256Length];
- uint8 output2[crypto::kSHA256Length];
+ uint8_t output1[crypto::kSHA256Length];
+ uint8_t output2[crypto::kSHA256Length];
scoped_ptr<crypto::SecureHash> ctx1(crypto::SecureHash::Create(
crypto::SecureHash::SHA256));
diff --git a/crypto/secure_util.cc b/crypto/secure_util.cc
index 3fe8aa9..fe86d65 100644
--- a/crypto/secure_util.cc
+++ b/crypto/secure_util.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 <stddef.h>
+
#include "crypto/secure_util.h"
namespace crypto {
diff --git a/crypto/sha2.cc b/crypto/sha2.cc
index 6f36237..2646d1b 100644
--- a/crypto/sha2.cc
+++ b/crypto/sha2.cc
@@ -4,6 +4,8 @@
#include "crypto/sha2.h"
+#include <stddef.h>
+
#include "base/memory/scoped_ptr.h"
#include "base/stl_util.h"
#include "crypto/secure_hash.h"
diff --git a/crypto/sha2.h b/crypto/sha2.h
index 7e279d3..d575815 100644
--- a/crypto/sha2.h
+++ b/crypto/sha2.h
@@ -5,6 +5,8 @@
#ifndef CRYPTO_SHA2_H_
#define CRYPTO_SHA2_H_
+#include <stddef.h>
+
#include <string>
#include "base/strings/string_piece.h"
diff --git a/crypto/sha2_unittest.cc b/crypto/sha2_unittest.cc
index 78da136..27d6d25 100644
--- a/crypto/sha2_unittest.cc
+++ b/crypto/sha2_unittest.cc
@@ -4,7 +4,9 @@
#include "crypto/sha2.h"
-#include "base/basictypes.h"
+#include <stddef.h>
+#include <stdint.h>
+
#include "testing/gtest/include/gtest/gtest.h"
TEST(Sha256Test, Test1) {
@@ -19,12 +21,12 @@ TEST(Sha256Test, Test1) {
0xb4, 0x10, 0xff, 0x61,
0xf2, 0x00, 0x15, 0xad };
- uint8 output1[crypto::kSHA256Length];
+ uint8_t output1[crypto::kSHA256Length];
crypto::SHA256HashString(input1, output1, sizeof(output1));
for (size_t i = 0; i < crypto::kSHA256Length; i++)
EXPECT_EQ(expected1[i], static_cast<int>(output1[i]));
- uint8 output_truncated1[4]; // 4 bytes == 32 bits
+ uint8_t output_truncated1[4]; // 4 bytes == 32 bits
crypto::SHA256HashString(input1,
output_truncated1, sizeof(output_truncated1));
for (size_t i = 0; i < sizeof(output_truncated1); i++)
@@ -47,7 +49,7 @@ TEST(Sha256Test, Test1_String) {
std::string output1 = crypto::SHA256HashString(input1);
ASSERT_EQ(crypto::kSHA256Length, output1.size());
for (size_t i = 0; i < crypto::kSHA256Length; i++)
- EXPECT_EQ(expected1[i], static_cast<uint8>(output1[i]));
+ EXPECT_EQ(expected1[i], static_cast<uint8_t>(output1[i]));
}
TEST(Sha256Test, Test2) {
@@ -63,12 +65,12 @@ TEST(Sha256Test, Test2) {
0xf6, 0xec, 0xed, 0xd4,
0x19, 0xdb, 0x06, 0xc1 };
- uint8 output2[crypto::kSHA256Length];
+ uint8_t output2[crypto::kSHA256Length];
crypto::SHA256HashString(input2, output2, sizeof(output2));
for (size_t i = 0; i < crypto::kSHA256Length; i++)
EXPECT_EQ(expected2[i], static_cast<int>(output2[i]));
- uint8 output_truncated2[6];
+ uint8_t output_truncated2[6];
crypto::SHA256HashString(input2,
output_truncated2, sizeof(output_truncated2));
for (size_t i = 0; i < sizeof(output_truncated2); i++)
@@ -87,12 +89,12 @@ TEST(Sha256Test, Test3) {
0x04, 0x6d, 0x39, 0xcc,
0xc7, 0x11, 0x2c, 0xd0 };
- uint8 output3[crypto::kSHA256Length];
+ uint8_t output3[crypto::kSHA256Length];
crypto::SHA256HashString(input3, output3, sizeof(output3));
for (size_t i = 0; i < crypto::kSHA256Length; i++)
EXPECT_EQ(expected3[i], static_cast<int>(output3[i]));
- uint8 output_truncated3[12];
+ uint8_t output_truncated3[12];
crypto::SHA256HashString(input3,
output_truncated3, sizeof(output_truncated3));
for (size_t i = 0; i < sizeof(output_truncated3); i++)
diff --git a/crypto/signature_creator.h b/crypto/signature_creator.h
index ab9d2c1..abd1546 100644
--- a/crypto/signature_creator.h
+++ b/crypto/signature_creator.h
@@ -5,10 +5,12 @@
#ifndef CRYPTO_SIGNATURE_CREATOR_H_
#define CRYPTO_SIGNATURE_CREATOR_H_
+#include <stdint.h>
+
#include <vector>
+#include "base/macros.h"
#include "build/build_config.h"
-#include "base/basictypes.h"
#include "crypto/crypto_export.h"
#if defined(USE_OPENSSL)
@@ -45,15 +47,15 @@ class CRYPTO_EXPORT SignatureCreator {
// specified in PKCS #1 v1.5.
static bool Sign(RSAPrivateKey* key,
HashAlgorithm hash_alg,
- const uint8* data,
+ const uint8_t* data,
int data_len,
- std::vector<uint8>* signature);
+ std::vector<uint8_t>* signature);
// Update the signature with more data.
- bool Update(const uint8* data_part, int data_part_len);
+ bool Update(const uint8_t* data_part, int data_part_len);
// Finalize the signature.
- bool Final(std::vector<uint8>* signature);
+ bool Final(std::vector<uint8_t>* signature);
private:
// Private constructor. Use the Create() method instead.
diff --git a/crypto/signature_creator_nss.cc b/crypto/signature_creator_nss.cc
index da03312..bf20413 100644
--- a/crypto/signature_creator_nss.cc
+++ b/crypto/signature_creator_nss.cc
@@ -6,6 +6,7 @@
#include <cryptohi.h>
#include <keyhi.h>
+#include <stdint.h>
#include <stdlib.h>
#include "base/logging.h"
@@ -68,9 +69,9 @@ SignatureCreator* SignatureCreator::Create(RSAPrivateKey* key,
// static
bool SignatureCreator::Sign(RSAPrivateKey* key,
HashAlgorithm hash_alg,
- const uint8* data,
+ const uint8_t* data,
int data_len,
- std::vector<uint8>* signature) {
+ std::vector<uint8_t>* signature) {
SECItem data_item;
data_item.type = siBuffer;
data_item.data = const_cast<unsigned char*>(data);
@@ -89,7 +90,7 @@ bool SignatureCreator::Sign(RSAPrivateKey* key,
return true;
}
-bool SignatureCreator::Update(const uint8* data_part, int data_part_len) {
+bool SignatureCreator::Update(const uint8_t* data_part, int data_part_len) {
SECStatus rv = SGN_Update(sign_context_, data_part, data_part_len);
if (rv != SECSuccess) {
NOTREACHED();
@@ -99,7 +100,7 @@ bool SignatureCreator::Update(const uint8* data_part, int data_part_len) {
return true;
}
-bool SignatureCreator::Final(std::vector<uint8>* signature) {
+bool SignatureCreator::Final(std::vector<uint8_t>* signature) {
SECItem signature_item;
SECStatus rv = SGN_End(sign_context_, &signature_item);
if (rv != SECSuccess) {
diff --git a/crypto/signature_creator_openssl.cc b/crypto/signature_creator_openssl.cc
index 3dc64cd..d5fc4d4 100644
--- a/crypto/signature_creator_openssl.cc
+++ b/crypto/signature_creator_openssl.cc
@@ -6,6 +6,8 @@
#include <openssl/evp.h>
#include <openssl/rsa.h>
+#include <stddef.h>
+#include <stdint.h>
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -59,9 +61,9 @@ SignatureCreator* SignatureCreator::Create(RSAPrivateKey* key,
// static
bool SignatureCreator::Sign(RSAPrivateKey* key,
HashAlgorithm hash_alg,
- const uint8* data,
+ const uint8_t* data,
int data_len,
- std::vector<uint8>* signature) {
+ std::vector<uint8_t>* signature) {
ScopedRSA rsa_key(EVP_PKEY_get1_RSA(key->key()));
if (!rsa_key)
return false;
@@ -85,12 +87,12 @@ SignatureCreator::~SignatureCreator() {
EVP_MD_CTX_destroy(sign_context_);
}
-bool SignatureCreator::Update(const uint8* data_part, int data_part_len) {
+bool SignatureCreator::Update(const uint8_t* data_part, int data_part_len) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
return !!EVP_DigestSignUpdate(sign_context_, data_part, data_part_len);
}
-bool SignatureCreator::Final(std::vector<uint8>* signature) {
+bool SignatureCreator::Final(std::vector<uint8_t>* signature) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
// Determine the maximum length of the signature.
diff --git a/crypto/signature_creator_unittest.cc b/crypto/signature_creator_unittest.cc
index 694becd..af1a042 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());
}
diff --git a/crypto/signature_verifier.h b/crypto/signature_verifier.h
index fbf87d4..b26a0df 100644
--- a/crypto/signature_verifier.h
+++ b/crypto/signature_verifier.h
@@ -5,10 +5,11 @@
#ifndef CRYPTO_SIGNATURE_VERIFIER_H_
#define CRYPTO_SIGNATURE_VERIFIER_H_
+#include <stdint.h>
+
#include <vector>
#include "build/build_config.h"
-#include "base/basictypes.h"
#include "crypto/crypto_export.h"
#if defined(USE_OPENSSL)
@@ -58,11 +59,11 @@ class CRYPTO_EXPORT SignatureVerifier {
// SubjectPublicKeyInfo ::= SEQUENCE {
// algorithm AlgorithmIdentifier,
// subjectPublicKey BIT STRING }
- bool VerifyInit(const uint8* signature_algorithm,
+ bool VerifyInit(const uint8_t* signature_algorithm,
int signature_algorithm_len,
- const uint8* signature,
+ const uint8_t* signature,
int signature_len,
- const uint8* public_key_info,
+ const uint8_t* public_key_info,
int public_key_info_len);
// Initiates a RSA-PSS signature verification operation. This should be
@@ -84,13 +85,13 @@ class CRYPTO_EXPORT SignatureVerifier {
bool VerifyInitRSAPSS(HashAlgorithm hash_alg,
HashAlgorithm mask_hash_alg,
int salt_len,
- const uint8* signature,
+ const uint8_t* signature,
int signature_len,
- const uint8* public_key_info,
+ const uint8_t* public_key_info,
int public_key_info_len);
// Feeds a piece of the data to the signature verifier.
- void VerifyUpdate(const uint8* data_part, int data_part_len);
+ void VerifyUpdate(const uint8_t* data_part, int data_part_len);
// Concludes a signature verification operation. Returns true if the
// signature is valid. Returns false if the signature is invalid or an
@@ -98,31 +99,31 @@ class CRYPTO_EXPORT SignatureVerifier {
bool VerifyFinal();
// Note: we can provide a one-shot interface if there is interest:
- // bool Verify(const uint8* data,
+ // bool Verify(const uint8_t* data,
// int data_len,
- // const uint8* signature_algorithm,
+ // const uint8_t* signature_algorithm,
// int signature_algorithm_len,
- // const uint8* signature,
+ // const uint8_t* signature,
// int signature_len,
- // const uint8* public_key_info,
+ // const uint8_t* public_key_info,
// int public_key_info_len);
private:
#if defined(USE_OPENSSL)
bool CommonInit(const EVP_MD* digest,
- const uint8* signature,
+ const uint8_t* signature,
int signature_len,
- const uint8* public_key_info,
+ const uint8_t* public_key_info,
int public_key_info_len,
EVP_PKEY_CTX** pkey_ctx);
#else
- static SECKEYPublicKey* DecodePublicKeyInfo(const uint8* public_key_info,
+ static SECKEYPublicKey* DecodePublicKeyInfo(const uint8_t* public_key_info,
int public_key_info_len);
#endif
void Reset();
- std::vector<uint8> signature_;
+ std::vector<uint8_t> signature_;
#if defined(USE_OPENSSL)
struct VerifyContext;
diff --git a/crypto/signature_verifier_nss.cc b/crypto/signature_verifier_nss.cc
index 5be620d..e6cd3e0 100644
--- a/crypto/signature_verifier_nss.cc
+++ b/crypto/signature_verifier_nss.cc
@@ -9,6 +9,7 @@
#include <pk11pub.h>
#include <secerr.h>
#include <sechash.h>
+#include <stdint.h>
#include <stdlib.h>
#include "base/logging.h"
@@ -73,11 +74,11 @@ SignatureVerifier::~SignatureVerifier() {
Reset();
}
-bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
+bool SignatureVerifier::VerifyInit(const uint8_t* signature_algorithm,
int signature_algorithm_len,
- const uint8* signature,
+ const uint8_t* signature,
int signature_len,
- const uint8* public_key_info,
+ const uint8_t* public_key_info,
int public_key_info_len) {
if (vfy_context_ || hash_context_)
return false;
@@ -97,7 +98,7 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
SECItem sig_alg_der;
sig_alg_der.type = siBuffer;
- sig_alg_der.data = const_cast<uint8*>(signature_algorithm);
+ sig_alg_der.data = const_cast<uint8_t*>(signature_algorithm);
sig_alg_der.len = signature_algorithm_len;
SECAlgorithmID sig_alg_id;
SECStatus rv;
@@ -112,7 +113,7 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
SECItem sig;
sig.type = siBuffer;
- sig.data = const_cast<uint8*>(signature);
+ sig.data = const_cast<uint8_t*>(signature);
sig.len = signature_len;
SECOidTag hash_alg_tag;
vfy_context_ = VFY_CreateContextWithAlgorithmID(public_key, &sig,
@@ -138,9 +139,9 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
bool SignatureVerifier::VerifyInitRSAPSS(HashAlgorithm hash_alg,
HashAlgorithm mask_hash_alg,
int salt_len,
- const uint8* signature,
+ const uint8_t* signature,
int signature_len,
- const uint8* public_key_info,
+ const uint8_t* public_key_info,
int public_key_info_len) {
if (vfy_context_ || hash_context_)
return false;
@@ -163,7 +164,7 @@ bool SignatureVerifier::VerifyInitRSAPSS(HashAlgorithm hash_alg,
return true;
}
-void SignatureVerifier::VerifyUpdate(const uint8* data_part,
+void SignatureVerifier::VerifyUpdate(const uint8_t* data_part,
int data_part_len) {
if (vfy_context_) {
SECStatus rv = VFY_Update(vfy_context_, data_part, data_part_len);
@@ -192,12 +193,12 @@ bool SignatureVerifier::VerifyFinal() {
// static
SECKEYPublicKey* SignatureVerifier::DecodePublicKeyInfo(
- const uint8* public_key_info,
+ const uint8_t* public_key_info,
int public_key_info_len) {
CERTSubjectPublicKeyInfo* spki = NULL;
SECItem spki_der;
spki_der.type = siBuffer;
- spki_der.data = const_cast<uint8*>(public_key_info);
+ spki_der.data = const_cast<uint8_t*>(public_key_info);
spki_der.len = public_key_info_len;
spki = SECKEY_DecodeDERSubjectPublicKeyInfo(&spki_der);
if (!spki)
diff --git a/crypto/signature_verifier_openssl.cc b/crypto/signature_verifier_openssl.cc
index 309cb4c..a756149 100644
--- a/crypto/signature_verifier_openssl.cc
+++ b/crypto/signature_verifier_openssl.cc
@@ -6,6 +6,7 @@
#include <openssl/evp.h>
#include <openssl/x509.h>
+#include <stdint.h>
#include <vector>
@@ -42,11 +43,11 @@ SignatureVerifier::~SignatureVerifier() {
Reset();
}
-bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
+bool SignatureVerifier::VerifyInit(const uint8_t* signature_algorithm,
int signature_algorithm_len,
- const uint8* signature,
+ const uint8_t* signature,
int signature_len,
- const uint8* public_key_info,
+ const uint8_t* public_key_info,
int public_key_info_len) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
ScopedOpenSSL<X509_ALGOR, X509_ALGOR_free> algorithm(
@@ -74,9 +75,9 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
bool SignatureVerifier::VerifyInitRSAPSS(HashAlgorithm hash_alg,
HashAlgorithm mask_hash_alg,
int salt_len,
- const uint8* signature,
+ const uint8_t* signature,
int signature_len,
- const uint8* public_key_info,
+ const uint8_t* public_key_info,
int public_key_info_len) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
const EVP_MD* const digest = ToOpenSSLDigest(hash_alg);
@@ -106,7 +107,7 @@ bool SignatureVerifier::VerifyInitRSAPSS(HashAlgorithm hash_alg,
return rv == 1;
}
-void SignatureVerifier::VerifyUpdate(const uint8* data_part,
+void SignatureVerifier::VerifyUpdate(const uint8_t* data_part,
int data_part_len) {
DCHECK(verify_context_);
OpenSSLErrStackTracer err_tracer(FROM_HERE);
@@ -126,9 +127,9 @@ bool SignatureVerifier::VerifyFinal() {
}
bool SignatureVerifier::CommonInit(const EVP_MD* digest,
- const uint8* signature,
+ const uint8_t* signature,
int signature_len,
- const uint8* public_key_info,
+ const uint8_t* public_key_info,
int public_key_info_len,
EVP_PKEY_CTX** pkey_ctx) {
if (verify_context_)
diff --git a/crypto/signature_verifier_unittest.cc b/crypto/signature_verifier_unittest.cc
index a661ff7..adcc885 100644
--- a/crypto/signature_verifier_unittest.cc
+++ b/crypto/signature_verifier_unittest.cc
@@ -4,6 +4,10 @@
#include "crypto/signature_verifier.h"
+#include <stddef.h>
+#include <stdint.h>
+
+#include "base/macros.h"
#include "base/numerics/safe_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -24,181 +28,174 @@ TEST(SignatureVerifierTest, BasicTest) {
// TBSCertificate ::= SEQUENCE {
// ... -- omitted, not important
// }
- const uint8 tbs_certificate[1017] = {
- 0x30, 0x82, 0x03, 0xf5, // a SEQUENCE of length 1013 (0x3f5)
- 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x03, 0x43, 0xdd, 0x63, 0x30, 0x0d,
- 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05,
- 0x00, 0x30, 0x81, 0xca, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04,
- 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55,
- 0x04, 0x08, 0x13, 0x07, 0x41, 0x72, 0x69, 0x7a, 0x6f, 0x6e, 0x61, 0x31,
- 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x0a, 0x53, 0x63,
- 0x6f, 0x74, 0x74, 0x73, 0x64, 0x61, 0x6c, 0x65, 0x31, 0x1a, 0x30, 0x18,
- 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x11, 0x47, 0x6f, 0x44, 0x61, 0x64,
- 0x64, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e,
- 0x31, 0x33, 0x30, 0x31, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x2a, 0x68,
- 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66,
- 0x69, 0x63, 0x61, 0x74, 0x65, 0x73, 0x2e, 0x67, 0x6f, 0x64, 0x61, 0x64,
- 0x64, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x73,
- 0x69, 0x74, 0x6f, 0x72, 0x79, 0x31, 0x30, 0x30, 0x2e, 0x06, 0x03, 0x55,
- 0x04, 0x03, 0x13, 0x27, 0x47, 0x6f, 0x20, 0x44, 0x61, 0x64, 0x64, 0x79,
- 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x43, 0x65, 0x72, 0x74,
- 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x41, 0x75,
- 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x11, 0x30, 0x0f, 0x06,
- 0x03, 0x55, 0x04, 0x05, 0x13, 0x08, 0x30, 0x37, 0x39, 0x36, 0x39, 0x32,
- 0x38, 0x37, 0x30, 0x1e, 0x17, 0x0d, 0x30, 0x38, 0x30, 0x33, 0x31, 0x38,
- 0x32, 0x33, 0x33, 0x35, 0x31, 0x39, 0x5a, 0x17, 0x0d, 0x31, 0x31, 0x30,
- 0x33, 0x31, 0x38, 0x32, 0x33, 0x33, 0x35, 0x31, 0x39, 0x5a, 0x30, 0x79,
- 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55,
- 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a,
- 0x43, 0x61, 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x12,
- 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x09, 0x43, 0x75, 0x70,
- 0x65, 0x72, 0x74, 0x69, 0x6e, 0x6f, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03,
- 0x55, 0x04, 0x0a, 0x13, 0x0a, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x49,
- 0x6e, 0x63, 0x2e, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0b,
- 0x13, 0x0c, 0x4d, 0x61, 0x63, 0x20, 0x4f, 0x53, 0x20, 0x46, 0x6f, 0x72,
- 0x67, 0x65, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
- 0x0c, 0x2a, 0x2e, 0x77, 0x65, 0x62, 0x6b, 0x69, 0x74, 0x2e, 0x6f, 0x72,
- 0x67, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
- 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30,
- 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xa7, 0x62, 0x79, 0x41, 0xda, 0x28,
- 0xf2, 0xc0, 0x4f, 0xe0, 0x25, 0xaa, 0xa1, 0x2e, 0x3b, 0x30, 0x94, 0xb5,
- 0xc9, 0x26, 0x3a, 0x1b, 0xe2, 0xd0, 0xcc, 0xa2, 0x95, 0xe2, 0x91, 0xc0,
- 0xf0, 0x40, 0x9e, 0x27, 0x6e, 0xbd, 0x6e, 0xde, 0x7c, 0xb6, 0x30, 0x5c,
- 0xb8, 0x9b, 0x01, 0x2f, 0x92, 0x04, 0xa1, 0xef, 0x4a, 0xb1, 0x6c, 0xb1,
- 0x7e, 0x8e, 0xcd, 0xa6, 0xf4, 0x40, 0x73, 0x1f, 0x2c, 0x96, 0xad, 0xff,
- 0x2a, 0x6d, 0x0e, 0xba, 0x52, 0x84, 0x83, 0xb0, 0x39, 0xee, 0xc9, 0x39,
- 0xdc, 0x1e, 0x34, 0xd0, 0xd8, 0x5d, 0x7a, 0x09, 0xac, 0xa9, 0xee, 0xca,
- 0x65, 0xf6, 0x85, 0x3a, 0x6b, 0xee, 0xe4, 0x5c, 0x5e, 0xf8, 0xda, 0xd1,
- 0xce, 0x88, 0x47, 0xcd, 0x06, 0x21, 0xe0, 0xb9, 0x4b, 0xe4, 0x07, 0xcb,
- 0x57, 0xdc, 0xca, 0x99, 0x54, 0xf7, 0x0e, 0xd5, 0x17, 0x95, 0x05, 0x2e,
- 0xe9, 0xb1, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x82, 0x01, 0xce, 0x30,
- 0x82, 0x01, 0xca, 0x30, 0x09, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x02,
- 0x30, 0x00, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x04, 0x04, 0x03,
- 0x02, 0x05, 0xa0, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x25, 0x04, 0x16,
- 0x30, 0x14, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01,
- 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x02, 0x30, 0x57,
- 0x06, 0x03, 0x55, 0x1d, 0x1f, 0x04, 0x50, 0x30, 0x4e, 0x30, 0x4c, 0xa0,
- 0x4a, 0xa0, 0x48, 0x86, 0x46, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f,
- 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x73,
- 0x2e, 0x67, 0x6f, 0x64, 0x61, 0x64, 0x64, 0x79, 0x2e, 0x63, 0x6f, 0x6d,
- 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x2f,
- 0x67, 0x6f, 0x64, 0x61, 0x64, 0x64, 0x79, 0x65, 0x78, 0x74, 0x65, 0x6e,
- 0x64, 0x65, 0x64, 0x69, 0x73, 0x73, 0x75, 0x69, 0x6e, 0x67, 0x33, 0x2e,
- 0x63, 0x72, 0x6c, 0x30, 0x52, 0x06, 0x03, 0x55, 0x1d, 0x20, 0x04, 0x4b,
- 0x30, 0x49, 0x30, 0x47, 0x06, 0x0b, 0x60, 0x86, 0x48, 0x01, 0x86, 0xfd,
- 0x6d, 0x01, 0x07, 0x17, 0x02, 0x30, 0x38, 0x30, 0x36, 0x06, 0x08, 0x2b,
- 0x06, 0x01, 0x05, 0x05, 0x07, 0x02, 0x01, 0x16, 0x2a, 0x68, 0x74, 0x74,
- 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63,
- 0x61, 0x74, 0x65, 0x73, 0x2e, 0x67, 0x6f, 0x64, 0x61, 0x64, 0x64, 0x79,
- 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74,
- 0x6f, 0x72, 0x79, 0x30, 0x7f, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05,
- 0x07, 0x01, 0x01, 0x04, 0x73, 0x30, 0x71, 0x30, 0x23, 0x06, 0x08, 0x2b,
- 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, 0x86, 0x17, 0x68, 0x74, 0x74,
- 0x70, 0x3a, 0x2f, 0x2f, 0x6f, 0x63, 0x73, 0x70, 0x2e, 0x67, 0x6f, 0x64,
- 0x61, 0x64, 0x64, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x4a, 0x06, 0x08,
- 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x02, 0x86, 0x3e, 0x68, 0x74,
- 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69,
- 0x63, 0x61, 0x74, 0x65, 0x73, 0x2e, 0x67, 0x6f, 0x64, 0x61, 0x64, 0x64,
- 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69,
- 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x67, 0x64, 0x5f, 0x69, 0x6e, 0x74, 0x65,
- 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x2e, 0x63, 0x72, 0x74,
- 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x48,
- 0xdf, 0x60, 0x32, 0xcc, 0x89, 0x01, 0xb6, 0xdc, 0x2f, 0xe3, 0x73, 0xb5,
- 0x9c, 0x16, 0x58, 0x32, 0x68, 0xa9, 0xc3, 0x30, 0x1f, 0x06, 0x03, 0x55,
- 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xfd, 0xac, 0x61, 0x32,
- 0x93, 0x6c, 0x45, 0xd6, 0xe2, 0xee, 0x85, 0x5f, 0x9a, 0xba, 0xe7, 0x76,
- 0x99, 0x68, 0xcc, 0xe7, 0x30, 0x23, 0x06, 0x03, 0x55, 0x1d, 0x11, 0x04,
- 0x1c, 0x30, 0x1a, 0x82, 0x0c, 0x2a, 0x2e, 0x77, 0x65, 0x62, 0x6b, 0x69,
- 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x82, 0x0a, 0x77, 0x65, 0x62, 0x6b, 0x69,
- 0x74, 0x2e, 0x6f, 0x72, 0x67
- };
+ const uint8_t tbs_certificate[1017] = {
+ 0x30, 0x82, 0x03, 0xf5, // a SEQUENCE of length 1013 (0x3f5)
+ 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x03, 0x43, 0xdd, 0x63, 0x30, 0x0d,
+ 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05,
+ 0x00, 0x30, 0x81, 0xca, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04,
+ 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55,
+ 0x04, 0x08, 0x13, 0x07, 0x41, 0x72, 0x69, 0x7a, 0x6f, 0x6e, 0x61, 0x31,
+ 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x0a, 0x53, 0x63,
+ 0x6f, 0x74, 0x74, 0x73, 0x64, 0x61, 0x6c, 0x65, 0x31, 0x1a, 0x30, 0x18,
+ 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x11, 0x47, 0x6f, 0x44, 0x61, 0x64,
+ 0x64, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e,
+ 0x31, 0x33, 0x30, 0x31, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x2a, 0x68,
+ 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66,
+ 0x69, 0x63, 0x61, 0x74, 0x65, 0x73, 0x2e, 0x67, 0x6f, 0x64, 0x61, 0x64,
+ 0x64, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x73,
+ 0x69, 0x74, 0x6f, 0x72, 0x79, 0x31, 0x30, 0x30, 0x2e, 0x06, 0x03, 0x55,
+ 0x04, 0x03, 0x13, 0x27, 0x47, 0x6f, 0x20, 0x44, 0x61, 0x64, 0x64, 0x79,
+ 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x43, 0x65, 0x72, 0x74,
+ 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x41, 0x75,
+ 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x11, 0x30, 0x0f, 0x06,
+ 0x03, 0x55, 0x04, 0x05, 0x13, 0x08, 0x30, 0x37, 0x39, 0x36, 0x39, 0x32,
+ 0x38, 0x37, 0x30, 0x1e, 0x17, 0x0d, 0x30, 0x38, 0x30, 0x33, 0x31, 0x38,
+ 0x32, 0x33, 0x33, 0x35, 0x31, 0x39, 0x5a, 0x17, 0x0d, 0x31, 0x31, 0x30,
+ 0x33, 0x31, 0x38, 0x32, 0x33, 0x33, 0x35, 0x31, 0x39, 0x5a, 0x30, 0x79,
+ 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55,
+ 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a,
+ 0x43, 0x61, 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x12,
+ 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x09, 0x43, 0x75, 0x70,
+ 0x65, 0x72, 0x74, 0x69, 0x6e, 0x6f, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03,
+ 0x55, 0x04, 0x0a, 0x13, 0x0a, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x49,
+ 0x6e, 0x63, 0x2e, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0b,
+ 0x13, 0x0c, 0x4d, 0x61, 0x63, 0x20, 0x4f, 0x53, 0x20, 0x46, 0x6f, 0x72,
+ 0x67, 0x65, 0x31, 0x15, 0x30, 0x13,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x01, 0x00, 0x01, 0xa3, 0x82, 0x01, 0xce, 0x30,
+ 0x82, 0x01, 0xca, 0x30, 0x09, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x02,
+ 0x30, 0x00, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x04, 0x04, 0x03,
+ 0x02, 0x05, 0xa0, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x25, 0x04, 0x16,
+ 0x30, 0x14, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01,
+ 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x02, 0x30, 0x57,
+ 0x06, 0x03, 0x55, 0x1d, 0x1f, 0x04, 0x50, 0x30, 0x4e, 0x30, 0x4c, 0xa0,
+ 0x4a, 0xa0, 0x48, 0x86, 0x46, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f,
+ 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x73,
+ 0x2e, 0x67, 0x6f, 0x64, 0x61, 0x64, 0x64, 0x79, 0x2e, 0x63, 0x6f, 0x6d,
+ 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x2f,
+ 0x67, 0x6f, 0x64, 0x61, 0x64, 0x64, 0x79, 0x65, 0x78, 0x74, 0x65, 0x6e,
+ 0x64, 0x65, 0x64, 0x69, 0x73, 0x73, 0x75, 0x69, 0x6e, 0x67, 0x33, 0x2e,
+ 0x63, 0x72, 0x6c, 0x30, 0x52, 0x06, 0x03, 0x55, 0x1d, 0x20, 0x04, 0x4b,
+ 0x30, 0x49, 0x30, 0x47, 0x06, 0x0b, 0x60, 0x86, 0x48, 0x01, 0x86, 0xfd,
+ 0x6d, 0x01, 0x07, 0x17, 0x02, 0x30, 0x38, 0x30, 0x36, 0x06, 0x08, 0x2b,
+ 0x06, 0x01, 0x05, 0x05, 0x07, 0x02, 0x01, 0x16, 0x2a, 0x68, 0x74, 0x74,
+ 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63,
+ 0x61, 0x74, 0x65, 0x73, 0x2e, 0x67, 0x6f, 0x64, 0x61, 0x64, 0x64, 0x79,
+ 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74,
+ 0x6f, 0x72, 0x79, 0x30, 0x7f, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05,
+ 0x07, 0x01, 0x01, 0x04, 0x73, 0x30, 0x71, 0x30, 0x23, 0x06, 0x08, 0x2b,
+ 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, 0x86, 0x17, 0x68, 0x74, 0x74,
+ 0x70, 0x3a, 0x2f, 0x2f, 0x6f, 0x63, 0x73, 0x70, 0x2e, 0x67, 0x6f, 0x64,
+ 0x61, 0x64, 0x64, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x4a, 0x06, 0x08,
+ 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x02, 0x86, 0x3e, 0x68, 0x74,
+ 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69,
+ 0x63, 0x61, 0x74, 0x65, 0x73, 0x2e, 0x67, 0x6f, 0x64, 0x61, 0x64, 0x64,
+ 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69,
+ 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x67, 0x64, 0x5f, 0x69, 0x6e, 0x74, 0x65,
+ 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x2e, 0x63, 0x72, 0x74,
+ 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x48,
+ 0xdf, 0x60, 0x32, 0xcc, 0x89, 0x01, 0xb6, 0xdc, 0x2f, 0xe3, 0x73, 0xb5,
+ 0x9c, 0x16, 0x58, 0x32, 0x68, 0xa9, 0xc3, 0x30, 0x1f, 0x06, 0x03, 0x55,
+ 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xfd, 0xac, 0x61, 0x32,
+ 0x93, 0x6c, 0x45, 0xd6, 0xe2, 0xee, 0x85, 0x5f, 0x9a, 0xba, 0xe7, 0x76,
+ 0x99, 0x68, 0xcc, 0xe7, 0x30, 0x23, 0x06, 0x03, 0x55, 0x1d, 0x11, 0x04,
+ 0x1c, 0x30, 0x1a, 0x82, 0x0c, 0x2a, 0x2e, 0x77, 0x65, 0x62, 0x6b, 0x69,
+ 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x82, 0x0a, 0x77, 0x65, 0x62, 0x6b, 0x69,
+ 0x74, 0x2e, 0x6f, 0x72, 0x67};
// The signature algorithm is specified as the following ASN.1 structure:
// AlgorithmIdentifier ::= SEQUENCE {
// algorithm OBJECT IDENTIFIER,
// parameters ANY DEFINED BY algorithm OPTIONAL }
//
- const uint8 signature_algorithm[15] = {
- 0x30, 0x0d, // a SEQUENCE of length 13 (0xd)
+ const uint8_t signature_algorithm[15] = {
+ 0x30, 0x0d, // a SEQUENCE of length 13 (0xd)
0x06, 0x09, // an OBJECT IDENTIFIER of length 9
- // 1.2.840.113549.1.1.5 - sha1WithRSAEncryption
- 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05,
- 0x05, 0x00, // a NULL of length 0
+ // 1.2.840.113549.1.1.5 - sha1WithRSAEncryption
+ 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05,
+ 0x00, // a NULL of length 0
};
// RSA signature, a big integer in the big-endian byte order.
- const uint8 signature[256] = {
- 0x1e, 0x6a,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7d, 0x9a, 0xba, 0x94, 0xc5, 0xc8, 0xc4, 0x4b, 0x98, 0xff,
+ 0x9a, 0x01, 0x31, 0x6d, 0xf9, 0x2b, 0x58, 0xe7, 0xe7, 0x2a, 0xc5, 0x4d,
+ 0xbb, 0xbb, 0xcd, 0x0d, 0x70, 0xe1, 0xad, 0x03, 0xf5, 0xfe, 0xf4, 0x84,
+ 0x71, 0x08, 0xd2, 0xbc, 0x04, 0x7b, 0x26, 0x1c, 0xa8, 0x0f, 0x9c, 0xd8,
+ 0x12, 0x6a, 0x6f, 0x2b, 0x67, 0xa1, 0x03, 0x80, 0x9a, 0x11, 0x0b, 0xe9,
+ 0xe0, 0xb5, 0xb3, 0xb8, 0x19, 0x4e, 0x0c, 0xa4, 0xd9, 0x2b, 0x3b, 0xc2,
+ 0xca, 0x20, 0xd3, 0x0c, 0xa4, 0xff, 0x93, 0x13, 0x1f, 0xfc, 0xba, 0x94,
+ 0x93, 0x8c, 0x64, 0x15, 0x2e, 0x28, 0xa9, 0x55, 0x8c, 0x2c, 0x48, 0xd3,
+ 0xd3, 0xc1, 0x50, 0x69, 0x19, 0xe8, 0x34, 0xd3, 0xf1, 0x04, 0x9f, 0x0a,
+ 0x7a, 0x21, 0x87, 0xbf, 0xb9, 0x59, 0x37, 0x2e, 0xf4, 0x71, 0xa5, 0x3e,
+ 0xbe, 0xcd, 0x70, 0x83, 0x18, 0xf8, 0x8a, 0x72, 0x85, 0x45, 0x1f, 0x08,
+ 0x01, 0x6f, 0x37, 0xf5, 0x2b, 0x7b, 0xea, 0xb9, 0x8b, 0xa3, 0xcc, 0xfd,
+ 0x35, 0x52, 0xdd, 0x66, 0xde, 0x4f, 0x30, 0xc5, 0x73, 0x81, 0xb6, 0xe8,
+ 0x3c, 0xd8, 0x48, 0x8a};
// The public key is specified as the following ASN.1 structure:
// SubjectPublicKeyInfo ::= SEQUENCE {
// algorithm AlgorithmIdentifier,
// subjectPublicKey BIT STRING }
- const uint8 public_key_info[294] = {
- 0x30, 0x82, 0x01, 0x22, // a SEQUENCE of length 290 (0x122)
+ const uint8_t public_key_info[294] = {
+ 0x30, 0x82, 0x01, 0x22, // a SEQUENCE of length 290 (0x122)
// algorithm
0x30, 0x0d, // a SEQUENCE of length 13
- 0x06, 0x09, // an OBJECT IDENTIFIER of length 9
- 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01,
- 0x05, 0x00, // a NULL of length 0
+ 0x06, 0x09, // an OBJECT IDENTIFIER of length 9
+ 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
+ 0x00, // a NULL of length 0
// subjectPublicKey
0x03, 0x82, 0x01, 0x0f, // a BIT STRING of length 271 (0x10f)
- 0x00, // number of unused bits
- 0x30, 0x82, 0x01, 0x0a, // a SEQUENCE of length 266 (0x10a)
- // modulus
- 0x02, 0x82, 0x01, 0x01, // an INTEGER of length 257 (0x101)
- 0x00, 0xc4, 0x2d, 0xd5, 0x15, 0x8c, 0x9c, 0x26, 0x4c, 0xec,
- 0x32, 0x35, 0xeb, 0x5f, 0xb8, 0x59, 0x01, 0x5a, 0xa6, 0x61,
- 0x81, 0x59, 0x3b, 0x70, 0x63, 0xab, 0xe3, 0xdc, 0x3d, 0xc7,
- 0x2a, 0xb8, 0xc9, 0x33, 0xd3, 0x79, 0xe4, 0x3a, 0xed, 0x3c,
- 0x30, 0x23, 0x84, 0x8e, 0xb3, 0x30, 0x14, 0xb6, 0xb2, 0x87,
- 0xc3, 0x3d, 0x95, 0x54, 0x04, 0x9e, 0xdf, 0x99, 0xdd, 0x0b,
- 0x25, 0x1e, 0x21, 0xde, 0x65, 0x29, 0x7e, 0x35, 0xa8, 0xa9,
- 0x54, 0xeb, 0xf6, 0xf7, 0x32, 0x39, 0xd4, 0x26, 0x55, 0x95,
- 0xad, 0xef, 0xfb, 0xfe, 0x58, 0x86, 0xd7, 0x9e, 0xf4, 0x00,
- 0x8d, 0x8c, 0x2a, 0x0c, 0xbd, 0x42, 0x04, 0xce, 0xa7, 0x3f,
- 0x04, 0xf6, 0xee, 0x80, 0xf2, 0xaa, 0xef, 0x52, 0xa1, 0x69,
- 0x66, 0xda, 0xbe, 0x1a, 0xad, 0x5d, 0xda, 0x2c, 0x66, 0xea,
- 0x1a, 0x6b, 0xbb, 0xe5, 0x1a, 0x51, 0x4a, 0x00, 0x2f, 0x48,
- 0xc7, 0x98, 0x75, 0xd8, 0xb9, 0x29, 0xc8, 0xee, 0xf8, 0x66,
- 0x6d, 0x0a, 0x9c, 0xb3, 0xf3, 0xfc, 0x78, 0x7c, 0xa2, 0xf8,
- 0xa3, 0xf2, 0xb5, 0xc3, 0xf3, 0xb9, 0x7a, 0x91, 0xc1, 0xa7,
- 0xe6, 0x25, 0x2e, 0x9c, 0xa8, 0xed, 0x12, 0x65, 0x6e, 0x6a,
- 0xf6, 0x12, 0x44, 0x53, 0x70, 0x30, 0x95, 0xc3, 0x9c, 0x2b,
- 0x58, 0x2b, 0x3d, 0x08, 0x74, 0x4a, 0xf2, 0xbe, 0x51, 0xb0,
- 0xbf, 0x87, 0xd0, 0x4c, 0x27, 0x58, 0x6b, 0xb5, 0x35, 0xc5,
- 0x9d, 0xaf, 0x17, 0x31, 0xf8, 0x0b, 0x8f, 0xee, 0xad, 0x81,
- 0x36, 0x05, 0x89, 0x08, 0x98, 0xcf, 0x3a, 0xaf, 0x25, 0x87,
- 0xc0, 0x49, 0xea, 0xa7, 0xfd, 0x67, 0xf7, 0x45, 0x8e, 0x97,
- 0xcc, 0x14, 0x39, 0xe2, 0x36, 0x85, 0xb5, 0x7e, 0x1a, 0x37,
- 0xfd, 0x16, 0xf6, 0x71, 0x11, 0x9a, 0x74, 0x30, 0x16, 0xfe,
- 0x13, 0x94, 0xa3, 0x3f, 0x84, 0x0d, 0x4f,
- // public exponent
- 0x02, 0x03, // an INTEGER of length 3
- 0x01, 0x00, 0x01
- };
+ 0x00, // number of unused bits
+ 0x30, 0x82, 0x01, 0x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c, 0xa8, 0xed, 0x12, 0x65,
+ 0x6e, 0x6a, 0xf6, 0x12, 0x44, 0x53, 0x70, 0x30, 0x95, 0xc3, 0x9c, 0x2b,
+ 0x58, 0x2b, 0x3d, 0x08, 0x74, 0x4a, 0xf2, 0xbe, 0x51, 0xb0, 0xbf, 0x87,
+ 0xd0, 0x4c, 0x27, 0x58, 0x6b, 0xb5, 0x35, 0xc5, 0x9d, 0xaf, 0x17, 0x31,
+ 0xf8, 0x0b, 0x8f, 0xee, 0xad, 0x81, 0x36, 0x05, 0x89, 0x08, 0x98, 0xcf,
+ 0x3a, 0xaf, 0x25, 0x87, 0xc0, 0x49, 0xea, 0xa7, 0xfd, 0x67, 0xf7, 0x45,
+ 0x8e, 0x97, 0xcc, 0x14, 0x39, 0xe2, 0x36, 0x85, 0xb5, 0x7e, 0x1a, 0x37,
+ 0xfd, 0x16, 0xf6, 0x71, 0x11, 0x9a, 0x74, 0x30, 0x16, 0xfe, 0x13, 0x94,
+ 0xa3, 0x3f, 0x84, 0x0d, 0x4f,
+ // public exponent
+ 0x02, 0x03, // an INTEGER of length 3
+ 0x01, 0x00, 0x01};
// We use the signature verifier to perform four signature verification
// tests.
@@ -230,7 +227,7 @@ TEST(SignatureVerifierTest, BasicTest) {
EXPECT_TRUE(ok);
// Test 3: verify the signature with incorrect data.
- uint8 bad_tbs_certificate[sizeof(tbs_certificate)];
+ uint8_t bad_tbs_certificate[sizeof(tbs_certificate)];
memcpy(bad_tbs_certificate, tbs_certificate, sizeof(tbs_certificate));
bad_tbs_certificate[10] += 1; // Corrupt one byte of the data.
ok = verifier.VerifyInit(signature_algorithm,
@@ -243,7 +240,7 @@ TEST(SignatureVerifierTest, BasicTest) {
EXPECT_FALSE(ok);
// Test 4: verify a bad signature.
- uint8 bad_signature[sizeof(signature)];
+ uint8_t bad_signature[sizeof(signature)];
memcpy(bad_signature, signature, sizeof(signature));
bad_signature[10] += 1; // Corrupt one byte of the signature.
ok = verifier.VerifyInit(signature_algorithm,
@@ -980,7 +977,7 @@ static const PSSTestVector pss_test[] = {
},
};
-static uint8 HexDigitValue(char digit) {
+static uint8_t HexDigitValue(char digit) {
if ('0' <= digit && digit <= '9')
return digit - '0';
if ('a' <= digit && digit <= 'f')
@@ -988,12 +985,12 @@ static uint8 HexDigitValue(char digit) {
return digit - 'A' + 10;
}
-static bool DecodeTestInput(const char* in, std::vector<uint8>* out) {
+static bool DecodeTestInput(const char* in, std::vector<uint8_t>* out) {
out->clear();
while (in[0] != '\0') {
if (!isxdigit(in[0]) || !isxdigit(in[1]) || in[2] != ' ')
return false;
- uint8 octet = HexDigitValue(in[0]) * 16 + HexDigitValue(in[1]);
+ uint8_t octet = HexDigitValue(in[0]) * 16 + HexDigitValue(in[1]);
out->push_back(octet);
in += 3;
}
@@ -1002,24 +999,24 @@ static bool DecodeTestInput(const char* in, std::vector<uint8>* out) {
// PrependASN1Length prepends an ASN.1 serialized length to the beginning of
// |out|.
-static void PrependASN1Length(std::vector<uint8>* out, size_t len) {
+static void PrependASN1Length(std::vector<uint8_t>* out, size_t len) {
if (len < 128) {
- out->insert(out->begin(), static_cast<uint8>(len));
+ out->insert(out->begin(), static_cast<uint8_t>(len));
} else if (len < 256) {
- out->insert(out->begin(), static_cast<uint8>(len));
+ out->insert(out->begin(), static_cast<uint8_t>(len));
out->insert(out->begin(), 0x81);
} else if (len < 0x10000) {
- out->insert(out->begin(), static_cast<uint8>(len));
- out->insert(out->begin(), static_cast<uint8>(len >> 8));
+ out->insert(out->begin(), static_cast<uint8_t>(len));
+ out->insert(out->begin(), static_cast<uint8_t>(len >> 8));
out->insert(out->begin(), 0x82);
} else {
CHECK(false) << "ASN.1 length not handled: " << len;
}
}
-static bool EncodeRSAPublicKey(const std::vector<uint8>& modulus_n,
- const std::vector<uint8>& public_exponent_e,
- std::vector<uint8>* public_key_info) {
+static bool EncodeRSAPublicKey(const std::vector<uint8_t>& modulus_n,
+ const std::vector<uint8_t>& public_exponent_e,
+ std::vector<uint8_t>* public_key_info) {
// The public key is specified as the following ASN.1 structure:
// SubjectPublicKeyInfo ::= SEQUENCE {
// algorithm AlgorithmIdentifier,
@@ -1035,9 +1032,9 @@ static bool EncodeRSAPublicKey(const std::vector<uint8>& modulus_n,
// modulus INTEGER, -- n
// publicExponent INTEGER -- e
// }
- static const uint8 kIntegerTag = 0x02;
- static const uint8 kBitStringTag = 0x03;
- static const uint8 kSequenceTag = 0x30;
+ static const uint8_t kIntegerTag = 0x02;
+ static const uint8_t kBitStringTag = 0x03;
+ static const uint8_t kSequenceTag = 0x30;
public_key_info->clear();
// Encode the public exponent e as an INTEGER.
@@ -1069,11 +1066,10 @@ static bool EncodeRSAPublicKey(const std::vector<uint8>& modulus_n,
public_key_info->insert(public_key_info->begin(), kBitStringTag);
// Encode the AlgorithmIdentifier.
- static const uint8 algorithm[] = {
- 0x30, 0x0d, // a SEQUENCE of length 13
+ static const uint8_t algorithm[] = {
+ 0x30, 0x0d, // a SEQUENCE of length 13
0x06, 0x09, // an OBJECT IDENTIFIER of length 9
- 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01,
- 0x05, 0x00,
+ 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00,
};
public_key_info->insert(public_key_info->begin(),
algorithm, algorithm + sizeof(algorithm));
@@ -1088,20 +1084,20 @@ static bool EncodeRSAPublicKey(const std::vector<uint8>& modulus_n,
TEST(SignatureVerifierTest, VerifyRSAPSS) {
for (unsigned int i = 0; i < arraysize(pss_test); i++) {
SCOPED_TRACE(i);
- std::vector<uint8> modulus_n;
- std::vector<uint8> public_exponent_e;
+ std::vector<uint8_t> modulus_n;
+ std::vector<uint8_t> public_exponent_e;
ASSERT_TRUE(DecodeTestInput(pss_test[i].modulus_n, &modulus_n));
ASSERT_TRUE(DecodeTestInput(pss_test[i].public_exponent_e,
&public_exponent_e));
- std::vector<uint8> public_key_info;
+ std::vector<uint8_t> public_key_info;
ASSERT_TRUE(EncodeRSAPublicKey(modulus_n, public_exponent_e,
&public_key_info));
for (unsigned int j = 0; j < arraysize(pss_test[i].example); j++) {
SCOPED_TRACE(j);
- std::vector<uint8> message;
- std::vector<uint8> salt;
- std::vector<uint8> signature;
+ std::vector<uint8_t> message;
+ std::vector<uint8_t> salt;
+ std::vector<uint8_t> signature;
ASSERT_TRUE(DecodeTestInput(pss_test[i].example[j].message, &message));
ASSERT_TRUE(DecodeTestInput(pss_test[i].example[j].salt, &salt));
ASSERT_TRUE(DecodeTestInput(pss_test[i].example[j].signature,
diff --git a/crypto/symmetric_key.h b/crypto/symmetric_key.h
index 996c592..14f74ae 100644
--- a/crypto/symmetric_key.h
+++ b/crypto/symmetric_key.h
@@ -5,9 +5,12 @@
#ifndef CRYPTO_SYMMETRIC_KEY_H_
#define CRYPTO_SYMMETRIC_KEY_H_
+#include <stddef.h>
+
#include <string>
-#include "base/basictypes.h"
+#include "base/macros.h"
+#include "build/build_config.h"
#include "crypto/crypto_export.h"
#if defined(NACL_WIN64)
diff --git a/crypto/symmetric_key_nss.cc b/crypto/symmetric_key_nss.cc
index 95ca9bd..e3aacc7 100644
--- a/crypto/symmetric_key_nss.cc
+++ b/crypto/symmetric_key_nss.cc
@@ -6,9 +6,11 @@
#include <nss.h>
#include <pk11pub.h>
+#include <stddef.h>
#include "base/logging.h"
#include "crypto/nss_util.h"
+#include "crypto/scoped_nss_types.h"
namespace crypto {
diff --git a/crypto/symmetric_key_openssl.cc b/crypto/symmetric_key_openssl.cc
index 912c9b4..2c5358f 100644
--- a/crypto/symmetric_key_openssl.cc
+++ b/crypto/symmetric_key_openssl.cc
@@ -6,6 +6,8 @@
#include <openssl/evp.h>
#include <openssl/rand.h>
+#include <stddef.h>
+#include <stdint.h>
#include <algorithm>
@@ -39,7 +41,7 @@ SymmetricKey* SymmetricKey::GenerateRandomKey(Algorithm algorithm,
OpenSSLErrStackTracer err_tracer(FROM_HERE);
scoped_ptr<SymmetricKey> key(new SymmetricKey);
- uint8* key_data = reinterpret_cast<uint8*>(
+ uint8_t* key_data = reinterpret_cast<uint8_t*>(
base::WriteInto(&key->key_, key_size_in_bytes + 1));
int rv = RAND_bytes(key_data, static_cast<int>(key_size_in_bytes));
@@ -70,13 +72,12 @@ SymmetricKey* SymmetricKey::DeriveKeyFromPassword(Algorithm algorithm,
OpenSSLErrStackTracer err_tracer(FROM_HERE);
scoped_ptr<SymmetricKey> key(new SymmetricKey);
- uint8* key_data = reinterpret_cast<uint8*>(
+ uint8_t* key_data = reinterpret_cast<uint8_t*>(
base::WriteInto(&key->key_, key_size_in_bytes + 1));
- int rv = PKCS5_PBKDF2_HMAC_SHA1(password.data(), password.length(),
- reinterpret_cast<const uint8*>(salt.data()),
- salt.length(), iterations,
- static_cast<int>(key_size_in_bytes),
- key_data);
+ int rv = PKCS5_PBKDF2_HMAC_SHA1(
+ password.data(), password.length(),
+ reinterpret_cast<const uint8_t*>(salt.data()), salt.length(), iterations,
+ static_cast<int>(key_size_in_bytes), key_data);
return rv == 1 ? key.release() : NULL;
}
diff --git a/crypto/symmetric_key_win.cc b/crypto/symmetric_key_win.cc
index efc7fe4..ac8e614 100644
--- a/crypto/symmetric_key_win.cc
+++ b/crypto/symmetric_key_win.cc
@@ -4,6 +4,9 @@
#include "crypto/symmetric_key.h"
+#include <stddef.h>
+#include <stdint.h>
+
#include <vector>
// TODO(wtc): replace scoped_array by std::vector.
@@ -239,7 +242,7 @@ bool ComputePBKDF2Block(HCRYPTHASH hash,
DWORD hash_size,
const std::string& salt,
size_t iterations,
- uint32 block_index,
+ uint32_t block_index,
BYTE* output_buf) {
// From RFC 2898:
// 3. <snip> The function F is defined as the exclusive-or sum of the first
@@ -263,7 +266,7 @@ bool ComputePBKDF2Block(HCRYPTHASH hash,
return false;
// Iteration U_1: and append (big-endian) INT (i).
- uint32 big_endian_block_index = base::HostToNet32(block_index);
+ uint32_t big_endian_block_index = base::HostToNet32(block_index);
ok = CryptHashData(safe_hash,
reinterpret_cast<BYTE*>(&big_endian_block_index),
sizeof(big_endian_block_index), 0);
@@ -440,7 +443,7 @@ SymmetricKey* SymmetricKey::DeriveKeyFromPassword(Algorithm algorithm,
// 4. Concatenate the blocks and extract the first dkLen octets to produce
// a derived key DK:
// DK = T_1 || T_2 || ... || T_l<0..r-1>
- for (uint32 block_index = 1; block_index <= L; ++block_index) {
+ for (uint32_t block_index = 1; block_index <= L; ++block_index) {
if (!ComputePBKDF2Block(prf, hLen, salt, iterations, block_index,
block_offset))
return NULL;
diff --git a/crypto/third_party/nss/secsign.cc b/crypto/third_party/nss/secsign.cc
index a788def..c9816fb0 100644
--- a/crypto/third_party/nss/secsign.cc
+++ b/crypto/third_party/nss/secsign.cc
@@ -46,8 +46,8 @@
#include <pk11pub.h>
#include <secerr.h>
#include <sechash.h>
+#include <stdint.h>
-#include "base/basictypes.h"
#include "base/logging.h"
#include "build/build_config.h"
@@ -88,7 +88,7 @@ SECStatus DerSignData(PLArenaPool *arena,
}
// Hash the input.
- std::vector<uint8> hash_data(HASH_ResultLen(hash_type));
+ std::vector<uint8_t> hash_data(HASH_ResultLen(hash_type));
SECStatus rv = HASH_HashBuf(
hash_type, &hash_data[0], input->data, input->len);
if (rv != SECSuccess)
@@ -98,7 +98,7 @@ SECStatus DerSignData(PLArenaPool *arena,
// Compute signature of hash.
int signature_len = PK11_SignatureLen(key);
- std::vector<uint8> signature_data(signature_len);
+ std::vector<uint8_t> signature_data(signature_len);
SECItem sig = {siBuffer, &signature_data[0],
static_cast<unsigned int>(signature_len)};
rv = PK11_Sign(key, &sig, &hash);