diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/cert/x509/x509_ext.cpp | 20 | ||||
-rw-r--r-- | src/lib/entropy/rdrand/rdrand.cpp | 2 | ||||
-rw-r--r-- | src/lib/entropy/rdseed/rdseed.cpp | 2 | ||||
-rw-r--r-- | src/lib/prov/tpm/tpm.cpp | 10 | ||||
-rw-r--r-- | src/lib/prov/tpm/tpm.h | 30 | ||||
-rw-r--r-- | src/tests/test_filters.cpp | 6 |
6 files changed, 40 insertions, 30 deletions
diff --git a/src/lib/cert/x509/x509_ext.cpp b/src/lib/cert/x509/x509_ext.cpp index f8f9adb2b..f3a9a7f1c 100644 --- a/src/lib/cert/x509/x509_ext.cpp +++ b/src/lib/cert/x509/x509_ext.cpp @@ -379,7 +379,9 @@ void Alternative_Name::contents_to(Data_Store& subject_info, * Alternative_Name Constructor */ Alternative_Name::Alternative_Name(const AlternativeName& alt_name, - const std::string& oid_name_str) : m_alt_name(alt_name), m_oid_name_str(oid_name_str) + const std::string& oid_name_str) : + m_oid_name_str(oid_name_str), + m_alt_name(alt_name) {} /* @@ -436,26 +438,28 @@ namespace { class Policy_Information : public ASN1_Object { public: - // public member variable: - OID oid; - Policy_Information() {} - explicit Policy_Information(const OID& oid) : oid(oid) {} + explicit Policy_Information(const OID& oid) : m_oid(oid) {} + + const OID& oid() const { return m_oid; } void encode_into(DER_Encoder& codec) const override { codec.start_cons(SEQUENCE) - .encode(oid) + .encode(m_oid) .end_cons(); } void decode_from(BER_Decoder& codec) override { codec.start_cons(SEQUENCE) - .decode(oid) + .decode(m_oid) .discard_remaining() .end_cons(); } + + private: + OID m_oid; }; } @@ -488,7 +492,7 @@ void Certificate_Policies::decode_inner(const std::vector<byte>& in) m_oids.clear(); for(size_t i = 0; i != policies.size(); ++i) - m_oids.push_back(policies[i].oid); + m_oids.push_back(policies[i].oid()); } /* diff --git a/src/lib/entropy/rdrand/rdrand.cpp b/src/lib/entropy/rdrand/rdrand.cpp index 13263bb63..89234b460 100644 --- a/src/lib/entropy/rdrand/rdrand.cpp +++ b/src/lib/entropy/rdrand/rdrand.cpp @@ -20,7 +20,7 @@ void Intel_Rdrand::poll(Entropy_Accumulator& accum) { if(!CPUID::has_rdrand()) return; - for(size_t i = 0; i != BOTAN_ENTROPY_INTEL_RNG_POLLS; ++i) + for(size_t p = 0; p != BOTAN_ENTROPY_INTEL_RNG_POLLS; ++p) { for(size_t i = 0; i != BOTAN_ENTROPY_RDRAND_RETRIES; ++i) { diff --git a/src/lib/entropy/rdseed/rdseed.cpp b/src/lib/entropy/rdseed/rdseed.cpp index bcef9ad83..2ba2075cc 100644 --- a/src/lib/entropy/rdseed/rdseed.cpp +++ b/src/lib/entropy/rdseed/rdseed.cpp @@ -19,7 +19,7 @@ void Intel_Rdseed::poll(Entropy_Accumulator& accum) { if(!CPUID::has_rdseed()) return; - for(size_t i = 0; i != BOTAN_ENTROPY_INTEL_RNG_POLLS; ++i) + for(size_t p = 0; p != BOTAN_ENTROPY_INTEL_RNG_POLLS; ++p) { for(size_t i = 0; i != BOTAN_ENTROPY_RDSEED_RETRIES; ++i) { diff --git a/src/lib/prov/tpm/tpm.cpp b/src/lib/prov/tpm/tpm.cpp index 9a29be395..c0b265b98 100644 --- a/src/lib/prov/tpm/tpm.cpp +++ b/src/lib/prov/tpm/tpm.cpp @@ -56,13 +56,14 @@ TSS_FLAG bit_flag(size_t bits) } } +#if 0 bool is_srk_uuid(const UUID& uuid) { static const byte srk[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; const std::vector<uint8_t>& b = uuid.binary_value(); return (b.size() == 16 && same_mem(b.data(), srk, 16)); } - +#endif #define TSPI_CHECK_SUCCESS(expr) do { \ TSS_RESULT res = expr; \ @@ -90,10 +91,11 @@ void set_policy_secret(TSS_HPOLICY policy, const char* secret) { if(secret) { + BYTE* as_b = const_cast<BYTE*>(reinterpret_cast<const BYTE*>(secret)); TSPI_CHECK_SUCCESS(::Tspi_Policy_SetSecret(policy, - TSS_SECRET_MODE_PLAIN, - std::strlen(secret), - (BYTE*)secret)); + TSS_SECRET_MODE_PLAIN, + std::strlen(secret), + as_b)); } else { diff --git a/src/lib/prov/tpm/tpm.h b/src/lib/prov/tpm/tpm.h index 7df232be3..4a9dcd3c6 100644 --- a/src/lib/prov/tpm/tpm.h +++ b/src/lib/prov/tpm/tpm.h @@ -138,32 +138,36 @@ class BOTAN_DLL TPM_PrivateKey : public Private_Key */ std::string register_key(TPM_Storage_Type storage_type); + /** + * Returns a copy of the public key + */ + std::unique_ptr<Public_Key> public_key() const; + + std::vector<uint8_t> export_blob() const; + + TPM_Context& ctx() const { return m_ctx; } + + TSS_HKEY handle() const { return m_key; } + /* * Returns the list of all keys (in URL format) registered with the system */ static std::vector<std::string> registered_keys(TPM_Context& ctx); - size_t estimated_strength() const; - - size_t max_input_bits() const; + size_t estimated_strength() const override; - AlgorithmIdentifier algorithm_identifier() const; + size_t max_input_bits() const override; - std::vector<byte> x509_subject_public_key() const; + AlgorithmIdentifier algorithm_identifier() const override; - secure_vector<byte> pkcs8_private_key() const; // not implemented + std::vector<byte> x509_subject_public_key() const override; - std::unique_ptr<Public_Key> public_key() const; + secure_vector<byte> pkcs8_private_key() const override; bool check_key(RandomNumberGenerator& rng, bool) const override; - std::string algo_name() const { return "RSA"; } // ??? - - std::vector<uint8_t> export_blob() const; - - TPM_Context& ctx() const { return m_ctx; } + std::string algo_name() const override { return "RSA"; } // ??? - TSS_HKEY handle() const { return m_key; } private: BigInt get_n() const; BigInt get_e() const; diff --git a/src/tests/test_filters.cpp b/src/tests/test_filters.cpp index 35d578789..b6bbf05c3 100644 --- a/src/tests/test_filters.cpp +++ b/src/tests/test_filters.cpp @@ -32,11 +32,11 @@ class Filter_Tests : public Test secqueue_result.test_eq("size of SecureQueue is correct", queue_a.size(), test_data.size()); secqueue_result.test_eq("0 bytes read so far from SecureQueue", queue_a.get_bytes_read(), 0); - uint8_t byte; - size_t bytes_read = queue_a.read_byte(byte); + uint8_t b; + size_t bytes_read = queue_a.read_byte(b); secqueue_result.test_eq("1 byte read", bytes_read, 1); - Botan::secure_vector<uint8_t> produced(byte); + Botan::secure_vector<uint8_t> produced(b); Botan::secure_vector<uint8_t> expected(test_data.at(0)); secqueue_result.test_eq("byte read is correct", produced, expected); |