diff options
author | René Korthaus <[email protected]> | 2016-02-18 15:54:37 +0100 |
---|---|---|
committer | René Korthaus <[email protected]> | 2016-02-18 16:13:55 +0100 |
commit | 3a8dcbed75892ee63d73e9f9310f811e6267e504 (patch) | |
tree | 7553c5eb2936898d65b89b2407d016306d257dd1 /src | |
parent | 0c76098cbaa8002fb89756d6fa2b02359f3f5f88 (diff) |
Fix remaining Wshadow warnings and enable on gcc and clang
Diffstat (limited to 'src')
-rw-r--r-- | src/build-data/cc/clang.txt | 2 | ||||
-rw-r--r-- | src/build-data/cc/gcc.txt | 2 | ||||
-rw-r--r-- | src/cli/asn1.cpp | 16 | ||||
-rw-r--r-- | src/cli/speed.cpp | 6 | ||||
-rw-r--r-- | src/cli/tls_server.cpp | 6 | ||||
-rw-r--r-- | src/lib/asn1/ber_dec.cpp | 10 | ||||
-rw-r--r-- | src/lib/cert/x509/x509_ext.cpp | 2 | ||||
-rw-r--r-- | src/lib/ffi/ffi.cpp | 124 | ||||
-rw-r--r-- | src/lib/hash/skein/skein_512.cpp | 4 | ||||
-rw-r--r-- | src/lib/hash/skein/skein_512.h | 2 | ||||
-rw-r--r-- | src/lib/math/ec_gfp/curve_nistp.cpp | 7 | ||||
-rw-r--r-- | src/lib/math/ec_gfp/point_gfp.cpp | 4 | ||||
-rw-r--r-- | src/lib/misc/srp6/srp6_files.h | 8 | ||||
-rw-r--r-- | src/lib/pubkey/curve25519/donna.cpp | 6 | ||||
-rw-r--r-- | src/lib/pubkey/mce/polyn_gf2m.cpp | 12 | ||||
-rw-r--r-- | src/lib/tls/msg_certificate.cpp | 6 |
16 files changed, 111 insertions, 106 deletions
diff --git a/src/build-data/cc/clang.txt b/src/build-data/cc/clang.txt index a00230e7a..cfeb8087b 100644 --- a/src/build-data/cc/clang.txt +++ b/src/build-data/cc/clang.txt @@ -10,7 +10,7 @@ add_framework_option "-framework " lang_flags "-std=c++11 -D_REENTRANT -fstack-protector" -warning_flags "-Wall -Wextra -Wpedantic -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wunreachable-code" +warning_flags "-Wall -Wextra -Wpedantic -Wshadow -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wunreachable-code" maintainer_warning_flags "-Qunused-arguments -Werror -Wno-error=unused-parameter -Wno-error=unused-variable -Wno-error=unreachable-code" compile_flags "-c" diff --git a/src/build-data/cc/gcc.txt b/src/build-data/cc/gcc.txt index d5eff4734..0687a6dd0 100644 --- a/src/build-data/cc/gcc.txt +++ b/src/build-data/cc/gcc.txt @@ -9,7 +9,7 @@ add_lib_option -l lang_flags "-std=c++11 -D_REENTRANT" maintainer_warning_flags "-Wold-style-cast -Werror -Wno-error=old-style-cast -Wno-error=zero-as-null-pointer-constant -Wno-error=unused-parameter -Wno-error=unused-variable -Wno-error=strict-overflow -Wsuggest-override" -warning_flags "-Wall -Wextra -Wpedantic -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor" +warning_flags "-Wall -Wextra -Wpedantic -Wshadow -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor" compile_flags "-c" debug_info_flags "-g" diff --git a/src/cli/asn1.cpp b/src/cli/asn1.cpp index 592f363b4..75ec5c3bb 100644 --- a/src/cli/asn1.cpp +++ b/src/cli/asn1.cpp @@ -274,31 +274,31 @@ void decode(Botan::BER_Decoder& decoder, size_t level) } else if(type_tag == Botan::OCTET_STRING) { - std::vector<uint8_t> bits; - data.decode(bits, type_tag); + std::vector<uint8_t> decoded_bits; + data.decode(decoded_bits, type_tag); try { - Botan::BER_Decoder inner(bits); + Botan::BER_Decoder inner(decoded_bits); decode(inner, level + 1); } catch(...) { emit(type_name(type_tag), level, length, - url_encode(bits)); + url_encode(decoded_bits)); } } else if(type_tag == Botan::BIT_STRING) { - std::vector<uint8_t> bits; - data.decode(bits, type_tag); + std::vector<uint8_t> decoded_bits; + data.decode(decoded_bits, type_tag); std::vector<bool> bit_set; - for(size_t i = 0; i != bits.size(); ++i) + for(size_t i = 0; i != decoded_bits.size(); ++i) for(size_t j = 0; j != 8; ++j) { - const bool bit = static_cast<bool>((bits[bits.size()-i-1] >> (7-j)) & 1); + const bool bit = static_cast<bool>((decoded_bits[decoded_bits.size()-i-1] >> (7-j)) & 1); bit_set.push_back(bit); } diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp index ed39827e5..b643bd605 100644 --- a/src/cli/speed.cpp +++ b/src/cli/speed.cpp @@ -694,10 +694,10 @@ class Speed final : public Command while(ka_timer.under(msec)) { - Botan::SymmetricKey key1 = ka_timer.run([&] { return ka1.derive_key(32, ka2_pub); }); - Botan::SymmetricKey key2 = ka_timer.run([&] { return ka2.derive_key(32, ka1_pub); }); + Botan::SymmetricKey symkey1 = ka_timer.run([&] { return ka1.derive_key(32, ka2_pub); }); + Botan::SymmetricKey symkey2 = ka_timer.run([&] { return ka2.derive_key(32, ka1_pub); }); - if(key1 != key2) + if(symkey1 != symkey1) { error_output() << "Key agreement mismatch in PK bench\n"; } diff --git a/src/cli/tls_server.cpp b/src/cli/tls_server.cpp index c802dbeb0..2ccacb1f7 100644 --- a/src/cli/tls_server.cpp +++ b/src/cli/tls_server.cpp @@ -138,11 +138,11 @@ class TLS_Server final : public Command while(server.is_active() && !pending_output.empty()) { - std::string s = pending_output.front(); + std::string output = pending_output.front(); pending_output.pop_front(); - server.send(s); + server.send(output); - if(s == "quit\n") + if(output == "quit\n") server.close(); } } diff --git a/src/lib/asn1/ber_dec.cpp b/src/lib/asn1/ber_dec.cpp index 1d981cb8b..ac676cd08 100644 --- a/src/lib/asn1/ber_dec.cpp +++ b/src/lib/asn1/ber_dec.cpp @@ -139,14 +139,14 @@ size_t find_eoc(DataSource* ber) /* * Check a type invariant on BER data */ -void BER_Object::assert_is_a(ASN1_Tag type_tag, ASN1_Tag class_tag) +void BER_Object::assert_is_a(ASN1_Tag type_tag_, ASN1_Tag class_tag_) { - if(this->type_tag != type_tag || this->class_tag != class_tag) + if(type_tag != type_tag_ || class_tag != class_tag_) throw BER_Decoding_Error("Tag mismatch when decoding got " + - std::to_string(this->type_tag) + "/" + - std::to_string(this->class_tag) + " expected " + std::to_string(type_tag) + "/" + - std::to_string(class_tag)); + std::to_string(class_tag) + " expected " + + std::to_string(type_tag_) + "/" + + std::to_string(class_tag_)); } /* diff --git a/src/lib/cert/x509/x509_ext.cpp b/src/lib/cert/x509/x509_ext.cpp index 5e5b60677..b4b918529 100644 --- a/src/lib/cert/x509/x509_ext.cpp +++ b/src/lib/cert/x509/x509_ext.cpp @@ -448,7 +448,7 @@ class Policy_Information : public ASN1_Object OID oid; Policy_Information() {} - Policy_Information(const OID& oid) : oid(oid) {} + Policy_Information(const OID& oid_) : oid(oid_) {} void encode_into(DER_Encoder& codec) const override { diff --git a/src/lib/ffi/ffi.cpp b/src/lib/ffi/ffi.cpp index 48591a774..c5decdcf2 100644 --- a/src/lib/ffi/ffi.cpp +++ b/src/lib/ffi/ffi.cpp @@ -167,7 +167,7 @@ inline int write_str_output(char out[], size_t* out_len, const std::string& str) return write_str_output(reinterpret_cast<uint8_t*>(out), out_len, str); } -#define BOTAN_FFI_DO(T, obj, block) apply_fn(obj, BOTAN_CURRENT_FUNCTION, [=](T& obj) { do { block } while(0); return 0; }) +#define BOTAN_FFI_DO(T, obj, param, block) apply_fn(obj, BOTAN_CURRENT_FUNCTION, [=](T& param) { do { block } while(0); return 0; }) } @@ -282,12 +282,12 @@ int botan_rng_destroy(botan_rng_t rng) int botan_rng_get(botan_rng_t rng, uint8_t* out, size_t out_len) { - return BOTAN_FFI_DO(Botan::RandomNumberGenerator, rng, { rng.randomize(out, out_len); }); + return BOTAN_FFI_DO(Botan::RandomNumberGenerator, rng, r, { r.randomize(out, out_len); }); } int botan_rng_reseed(botan_rng_t rng, size_t bits) { - return BOTAN_FFI_DO(Botan::RandomNumberGenerator, rng, { rng.reseed(bits); }); + return BOTAN_FFI_DO(Botan::RandomNumberGenerator, rng, r, { r.reseed(bits); }); } int botan_hash_init(botan_hash_t* hash, const char* hash_name, uint32_t flags) @@ -326,22 +326,22 @@ int botan_hash_destroy(botan_hash_t hash) int botan_hash_output_length(botan_hash_t hash, size_t* out) { - return BOTAN_FFI_DO(Botan::HashFunction, hash, { *out = hash.output_length(); }); + return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { *out = h.output_length(); }); } int botan_hash_clear(botan_hash_t hash) { - return BOTAN_FFI_DO(Botan::HashFunction, hash, { hash.clear(); }); + return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { h.clear(); }); } int botan_hash_update(botan_hash_t hash, const uint8_t* buf, size_t len) { - return BOTAN_FFI_DO(Botan::HashFunction, hash, { hash.update(buf, len); }); + return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { h.update(buf, len); }); } int botan_hash_final(botan_hash_t hash, uint8_t out[]) { - return BOTAN_FFI_DO(Botan::HashFunction, hash, { hash.final(out); }); + return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { h.final(out); }); } int botan_mac_init(botan_mac_t* mac, const char* mac_name, uint32_t flags) @@ -378,27 +378,27 @@ int botan_mac_destroy(botan_mac_t mac) int botan_mac_set_key(botan_mac_t mac, const uint8_t* key, size_t key_len) { - return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, { mac.set_key(key, key_len); }); + return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, m, { m.set_key(key, key_len); }); } int botan_mac_output_length(botan_mac_t mac, size_t* out) { - return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, { *out = mac.output_length(); }); + return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, m, { *out = m.output_length(); }); } int botan_mac_clear(botan_mac_t mac) { - return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, { mac.clear(); }); + return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, m, { m.clear(); }); } int botan_mac_update(botan_mac_t mac, const uint8_t* buf, size_t len) { - return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, { mac.update(buf, len); }); + return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, m, { m.update(buf, len); }); } int botan_mac_final(botan_mac_t mac, uint8_t out[]) { - return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, { mac.final(out); }); + return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, m, { m.final(out); }); } int botan_cipher_init(botan_cipher_t* cipher, const char* cipher_name, uint32_t flags) @@ -433,23 +433,23 @@ int botan_cipher_destroy(botan_cipher_t cipher) int botan_cipher_clear(botan_cipher_t cipher) { - return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, { cipher.clear(); }); + return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, c, { c.clear(); }); } int botan_cipher_query_keylen(botan_cipher_t cipher, size_t* out_minimum_keylength, size_t* out_maximum_keylength) { - return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, { - *out_minimum_keylength = cipher.key_spec().minimum_keylength(); - *out_maximum_keylength = cipher.key_spec().maximum_keylength(); + return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, c, { + *out_minimum_keylength = c.key_spec().minimum_keylength(); + *out_maximum_keylength = c.key_spec().maximum_keylength(); }); } int botan_cipher_set_key(botan_cipher_t cipher, const uint8_t* key, size_t key_len) { - return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, { cipher.set_key(key, key_len); }); + return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, c, { c.set_key(key, key_len); }); } int botan_cipher_start(botan_cipher_t cipher_obj, @@ -579,8 +579,8 @@ int botan_cipher_set_associated_data(botan_cipher_t cipher, const uint8_t* ad, size_t ad_len) { - return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, { - if(Botan::AEAD_Mode* aead = dynamic_cast<Botan::AEAD_Mode*>(&cipher)) + return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, c, { + if(Botan::AEAD_Mode* aead = dynamic_cast<Botan::AEAD_Mode*>(&c)) { aead->set_associated_data(ad, ad_len); return 0; @@ -591,22 +591,22 @@ int botan_cipher_set_associated_data(botan_cipher_t cipher, int botan_cipher_valid_nonce_length(botan_cipher_t cipher, size_t nl) { - return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, { return cipher.valid_nonce_length(nl) ? 1 : 0; }); + return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, c, { return c.valid_nonce_length(nl) ? 1 : 0; }); } int botan_cipher_get_default_nonce_length(botan_cipher_t cipher, size_t* nl) { - return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, { *nl = cipher.default_nonce_length(); }); + return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, c, { *nl = c.default_nonce_length(); }); } int botan_cipher_get_update_granularity(botan_cipher_t cipher, size_t* ug) { - return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, { *ug = cipher.update_granularity(); }); + return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, c, { *ug = c.update_granularity(); }); } int botan_cipher_get_tag_length(botan_cipher_t cipher, size_t* tl) { - return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, { *tl = cipher.tag_size(); }); + return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, c, { *tl = c.tag_size(); }); } int botan_pbkdf(const char* pbkdf_algo, uint8_t out[], size_t out_len, @@ -909,16 +909,16 @@ int botan_privkey_export_pubkey(botan_pubkey_t* pubout, botan_privkey_t key_obj) int botan_pubkey_algo_name(botan_pubkey_t key, char out[], size_t* out_len) { - return BOTAN_FFI_DO(Botan::Public_Key, key, { return write_str_output(out, out_len, key.algo_name()); }); + return BOTAN_FFI_DO(Botan::Public_Key, key, k, { return write_str_output(out, out_len, k.algo_name()); }); } int botan_pubkey_export(botan_pubkey_t key, uint8_t out[], size_t* out_len, uint32_t flags) { - return BOTAN_FFI_DO(Botan::Public_Key, key, { + return BOTAN_FFI_DO(Botan::Public_Key, key, k, { if(flags == BOTAN_PRIVKEY_EXPORT_FLAG_DER) - return write_vec_output(out, out_len, Botan::X509::BER_encode(key)); + return write_vec_output(out, out_len, Botan::X509::BER_encode(k)); else if(flags == BOTAN_PRIVKEY_EXPORT_FLAG_PEM) - return write_str_output(out, out_len, Botan::X509::PEM_encode(key)); + return write_str_output(out, out_len, Botan::X509::PEM_encode(k)); else return -2; }); @@ -926,11 +926,11 @@ int botan_pubkey_export(botan_pubkey_t key, uint8_t out[], size_t* out_len, uint int botan_privkey_export(botan_privkey_t key, uint8_t out[], size_t* out_len, uint32_t flags) { - return BOTAN_FFI_DO(Botan::Private_Key, key, { + return BOTAN_FFI_DO(Botan::Private_Key, key, k, { if(flags == BOTAN_PRIVKEY_EXPORT_FLAG_DER) - return write_vec_output(out, out_len, Botan::PKCS8::BER_encode(key)); + return write_vec_output(out, out_len, Botan::PKCS8::BER_encode(k)); else if(flags == BOTAN_PRIVKEY_EXPORT_FLAG_PEM) - return write_str_output(out, out_len, Botan::PKCS8::PEM_encode(key)); + return write_str_output(out, out_len, Botan::PKCS8::PEM_encode(k)); else return -2; }); @@ -943,14 +943,14 @@ int botan_privkey_export_encrypted(botan_privkey_t key, const char* pbe, uint32_t flags) { - return BOTAN_FFI_DO(Botan::Private_Key, key, { + return BOTAN_FFI_DO(Botan::Private_Key, key, k, { auto pbkdf_time = std::chrono::milliseconds(300); Botan::RandomNumberGenerator& rng = safe_get(rng_obj); if(flags == BOTAN_PRIVKEY_EXPORT_FLAG_DER) - return write_vec_output(out, out_len, Botan::PKCS8::BER_encode(key, rng, pass, pbkdf_time, pbe)); + return write_vec_output(out, out_len, Botan::PKCS8::BER_encode(k, rng, pass, pbkdf_time, pbe)); else if(flags == BOTAN_PRIVKEY_EXPORT_FLAG_PEM) - return write_str_output(out, out_len, Botan::PKCS8::PEM_encode(key, rng, pass, pbkdf_time, pbe)); + return write_str_output(out, out_len, Botan::PKCS8::PEM_encode(k, rng, pass, pbkdf_time, pbe)); else return -2; }); @@ -958,15 +958,15 @@ int botan_privkey_export_encrypted(botan_privkey_t key, int botan_pubkey_estimated_strength(botan_pubkey_t key, size_t* estimate) { - return BOTAN_FFI_DO(Botan::Public_Key, key, { *estimate = key.estimated_strength(); }); + return BOTAN_FFI_DO(Botan::Public_Key, key, k, { *estimate = k.estimated_strength(); }); } int botan_pubkey_fingerprint(botan_pubkey_t key, const char* hash_fn, uint8_t out[], size_t* out_len) { - return BOTAN_FFI_DO(Botan::Public_Key, key, { + return BOTAN_FFI_DO(Botan::Public_Key, key, k, { std::unique_ptr<Botan::HashFunction> h(Botan::HashFunction::create(hash_fn)); - return write_vec_output(out, out_len, h->process(key.x509_subject_public_key())); + return write_vec_output(out, out_len, h->process(k.x509_subject_public_key())); }); } @@ -1007,8 +1007,8 @@ int botan_pk_op_encrypt(botan_pk_op_encrypt_t op, uint8_t out[], size_t* out_len, const uint8_t plaintext[], size_t plaintext_len) { - return BOTAN_FFI_DO(Botan::PK_Encryptor, op, { - return write_vec_output(out, out_len, op.encrypt(plaintext, plaintext_len, safe_get(rng_obj))); + return BOTAN_FFI_DO(Botan::PK_Encryptor, op, o, { + return write_vec_output(out, out_len, o.encrypt(plaintext, plaintext_len, safe_get(rng_obj))); }); } @@ -1051,8 +1051,8 @@ int botan_pk_op_decrypt(botan_pk_op_decrypt_t op, uint8_t out[], size_t* out_len, uint8_t ciphertext[], size_t ciphertext_len) { - return BOTAN_FFI_DO(Botan::PK_Decryptor, op, { - return write_vec_output(out, out_len, op.decrypt(ciphertext, ciphertext_len)); + return BOTAN_FFI_DO(Botan::PK_Decryptor, op, o, { + return write_vec_output(out, out_len, o.decrypt(ciphertext, ciphertext_len)); }); } @@ -1093,13 +1093,13 @@ int botan_pk_op_sign_destroy(botan_pk_op_sign_t op) int botan_pk_op_sign_update(botan_pk_op_sign_t op, const uint8_t in[], size_t in_len) { - return BOTAN_FFI_DO(Botan::PK_Signer, op, { op.update(in, in_len); }); + return BOTAN_FFI_DO(Botan::PK_Signer, op, o, { o.update(in, in_len); }); } int botan_pk_op_sign_finish(botan_pk_op_sign_t op, botan_rng_t rng_obj, uint8_t out[], size_t* out_len) { - return BOTAN_FFI_DO(Botan::PK_Signer, op, { - return write_vec_output(out, out_len, op.signature(safe_get(rng_obj))); + return BOTAN_FFI_DO(Botan::PK_Signer, op, o, { + return write_vec_output(out, out_len, o.signature(safe_get(rng_obj))); }); } @@ -1135,13 +1135,13 @@ int botan_pk_op_verify_destroy(botan_pk_op_verify_t op) int botan_pk_op_verify_update(botan_pk_op_verify_t op, const uint8_t in[], size_t in_len) { - return BOTAN_FFI_DO(Botan::PK_Verifier, op, { op.update(in, in_len); }); + return BOTAN_FFI_DO(Botan::PK_Verifier, op, o, { o.update(in, in_len); }); } int botan_pk_op_verify_finish(botan_pk_op_verify_t op, const uint8_t sig[], size_t sig_len) { - return BOTAN_FFI_DO(Botan::PK_Verifier, op, { - const bool legit = op.check_signature(sig, sig_len); + return BOTAN_FFI_DO(Botan::PK_Verifier, op, o, { + const bool legit = o.check_signature(sig, sig_len); if(legit) return 0; @@ -1185,8 +1185,8 @@ int botan_pk_op_key_agreement_destroy(botan_pk_op_ka_t op) int botan_pk_op_key_agreement_export_public(botan_privkey_t key, uint8_t out[], size_t* out_len) { - return BOTAN_FFI_DO(Botan::Private_Key, key, { - if(auto kak = dynamic_cast<const Botan::PK_Key_Agreement_Key*>(&key)) + return BOTAN_FFI_DO(Botan::Private_Key, key, k, { + if(auto kak = dynamic_cast<const Botan::PK_Key_Agreement_Key*>(&k)) return write_vec_output(out, out_len, kak->public_value()); return -2; }); @@ -1197,8 +1197,8 @@ int botan_pk_op_key_agreement(botan_pk_op_ka_t op, const uint8_t other_key[], size_t other_key_len, const uint8_t salt[], size_t salt_len) { - return BOTAN_FFI_DO(Botan::PK_Key_Agreement, op, { - auto k = op.derive_key(*out_len, other_key, other_key_len, salt, salt_len).bits_of(); + return BOTAN_FFI_DO(Botan::PK_Key_Agreement, op, o, { + auto k = o.derive_key(*out_len, other_key, other_key_len, salt, salt_len).bits_of(); return write_vec_output(out, out_len, k); }); } @@ -1268,37 +1268,37 @@ int botan_x509_cert_destroy(botan_x509_cert_t cert) int botan_x509_cert_get_time_starts(botan_x509_cert_t cert, char out[], size_t* out_len) { - return BOTAN_FFI_DO(Botan::X509_Certificate, cert, { return write_str_output(out, out_len, cert.start_time()); }); + return BOTAN_FFI_DO(Botan::X509_Certificate, cert, c, { return write_str_output(out, out_len, c.start_time()); }); } int botan_x509_cert_get_time_expires(botan_x509_cert_t cert, char out[], size_t* out_len) { - return BOTAN_FFI_DO(Botan::X509_Certificate, cert, { return write_str_output(out, out_len, cert.end_time()); }); + return BOTAN_FFI_DO(Botan::X509_Certificate, cert, c, { return write_str_output(out, out_len, c.end_time()); }); } int botan_x509_cert_get_serial_number(botan_x509_cert_t cert, uint8_t out[], size_t* out_len) { - return BOTAN_FFI_DO(Botan::X509_Certificate, cert, { return write_vec_output(out, out_len, cert.serial_number()); }); + return BOTAN_FFI_DO(Botan::X509_Certificate, cert, c, { return write_vec_output(out, out_len, c.serial_number()); }); } int botan_x509_cert_get_fingerprint(botan_x509_cert_t cert, const char* hash, uint8_t out[], size_t* out_len) { - return BOTAN_FFI_DO(Botan::X509_Certificate, cert, { return write_str_output(out, out_len, cert.fingerprint(hash)); }); + return BOTAN_FFI_DO(Botan::X509_Certificate, cert, c, { return write_str_output(out, out_len, c.fingerprint(hash)); }); } int botan_x509_cert_get_authority_key_id(botan_x509_cert_t cert, uint8_t out[], size_t* out_len) { - return BOTAN_FFI_DO(Botan::X509_Certificate, cert, { return write_vec_output(out, out_len, cert.authority_key_id()); }); + return BOTAN_FFI_DO(Botan::X509_Certificate, cert, c, { return write_vec_output(out, out_len, c.authority_key_id()); }); } int botan_x509_cert_get_subject_key_id(botan_x509_cert_t cert, uint8_t out[], size_t* out_len) { - return BOTAN_FFI_DO(Botan::X509_Certificate, cert, { return write_vec_output(out, out_len, cert.subject_key_id()); }); + return BOTAN_FFI_DO(Botan::X509_Certificate, cert, c, { return write_vec_output(out, out_len, c.subject_key_id()); }); } int botan_x509_cert_get_public_key_bits(botan_x509_cert_t cert, uint8_t out[], size_t* out_len) { - return BOTAN_FFI_DO(Botan::X509_Certificate, cert, { return write_vec_output(out, out_len, cert.subject_public_key_bits()); }); + return BOTAN_FFI_DO(Botan::X509_Certificate, cert, c, { return write_vec_output(out, out_len, c.subject_public_key_bits()); }); } @@ -1318,26 +1318,26 @@ int botan_x509_cert_get_issuer_dn(botan_x509_cert_t cert, const char* key, size_t index, uint8_t out[], size_t* out_len) { - return BOTAN_FFI_DO(Botan::X509_Certificate, cert, { return write_str_output(out, out_len, cert.issuer_info(key).at(index)); }); + return BOTAN_FFI_DO(Botan::X509_Certificate, cert, c, { return write_str_output(out, out_len, c.issuer_info(key).at(index)); }); } int botan_x509_cert_get_subject_dn(botan_x509_cert_t cert, const char* key, size_t index, uint8_t out[], size_t* out_len) { - return BOTAN_FFI_DO(Botan::X509_Certificate, cert, { return write_str_output(out, out_len, cert.subject_info(key).at(index)); }); + return BOTAN_FFI_DO(Botan::X509_Certificate, cert, c, { return write_str_output(out, out_len, c.subject_info(key).at(index)); }); } int botan_x509_cert_to_string(botan_x509_cert_t cert, char out[], size_t* out_len) { - return BOTAN_FFI_DO(Botan::X509_Certificate, cert, { return write_str_output(out, out_len, cert.to_string()); }); + return BOTAN_FFI_DO(Botan::X509_Certificate, cert, c, { return write_str_output(out, out_len, c.to_string()); }); } int botan_x509_cert_allowed_usage(botan_x509_cert_t cert, unsigned int key_usage) { - return BOTAN_FFI_DO(Botan::X509_Certificate, cert, { + return BOTAN_FFI_DO(Botan::X509_Certificate, cert, c, { const Botan::Key_Constraints k = static_cast<Botan::Key_Constraints>(key_usage); - if(cert.allowed_usage(k)) + if(c.allowed_usage(k)) return 0; return 1; }); diff --git a/src/lib/hash/skein/skein_512.cpp b/src/lib/hash/skein/skein_512.cpp index ad0817da7..86ea9e75a 100644 --- a/src/lib/hash/skein/skein_512.cpp +++ b/src/lib/hash/skein/skein_512.cpp @@ -51,13 +51,13 @@ void Skein_512::clear() initial_block(); } -void Skein_512::reset_tweak(type_code type, bool final) +void Skein_512::reset_tweak(type_code type, bool is_final) { m_T[0] = 0; m_T[1] = (static_cast<u64bit>(type) << 56) | (static_cast<u64bit>(1) << 62) | - (static_cast<u64bit>(final) << 63); + (static_cast<u64bit>(is_final) << 63); } void Skein_512::initial_block() diff --git a/src/lib/hash/skein/skein_512.h b/src/lib/hash/skein/skein_512.h index b9d0deb2e..001d9a991 100644 --- a/src/lib/hash/skein/skein_512.h +++ b/src/lib/hash/skein/skein_512.h @@ -55,7 +55,7 @@ class BOTAN_DLL Skein_512 final : public HashFunction void ubi_512(const byte msg[], size_t msg_len); void initial_block(); - void reset_tweak(type_code type, bool final); + void reset_tweak(type_code type, bool is_final); std::string m_personalization; size_t m_output_bits; diff --git a/src/lib/math/ec_gfp/curve_nistp.cpp b/src/lib/math/ec_gfp/curve_nistp.cpp index 6a98d9588..c153340e9 100644 --- a/src/lib/math/ec_gfp/curve_nistp.cpp +++ b/src/lib/math/ec_gfp/curve_nistp.cpp @@ -32,8 +32,11 @@ void normalize(const BigInt& p, BigInt& x, secure_vector<word>& ws, size_t bound const word* xd = x.data(); word borrow = 0; - for(size_t i = 0; i != p_words; ++i) - ws[i] = word_sub(xd[i], prime[i], &borrow); + for(size_t j = 0; j != p_words; ++j) + { + ws[j] = word_sub(xd[j], prime[j], &borrow); + } + ws[p_words] = word_sub(xd[p_words], 0, &borrow); if(borrow) diff --git a/src/lib/math/ec_gfp/point_gfp.cpp b/src/lib/math/ec_gfp/point_gfp.cpp index 5e8b3b4ef..f15911db0 100644 --- a/src/lib/math/ec_gfp/point_gfp.cpp +++ b/src/lib/math/ec_gfp/point_gfp.cpp @@ -421,8 +421,8 @@ PointGFp Blinded_Point_Multiply::blinded_multiply(const BigInt& scalar_in, for(size_t i = 0; i != m_h; ++i) R.mult2(m_ws); - const u32bit nibble = scalar.get_substring((windows-1)*m_h, m_h); - R.add(m_U[nibble], m_ws); + const u32bit inner_nibble = scalar.get_substring((windows-1)*m_h, m_h); + R.add(m_U[inner_nibble], m_ws); windows--; } } diff --git a/src/lib/misc/srp6/srp6_files.h b/src/lib/misc/srp6/srp6_files.h index a3b979b87..7d6d9a55b 100644 --- a/src/lib/misc/srp6/srp6_files.h +++ b/src/lib/misc/srp6/srp6_files.h @@ -35,10 +35,10 @@ class BOTAN_DLL SRP6_Authenticator_File { SRP6_Data() {} - SRP6_Data(const BigInt& v, - const std::vector<byte>& salt, - const std::string& group_id) : - v(v), salt(salt), group_id(group_id) {} + SRP6_Data(const BigInt& v_, + const std::vector<byte>& salt_, + const std::string& group_id_) : + v(v_), salt(salt_), group_id(group_id_) {} // public member variable: BigInt v; diff --git a/src/lib/pubkey/curve25519/donna.cpp b/src/lib/pubkey/curve25519/donna.cpp index 78966f745..9b28e412c 100644 --- a/src/lib/pubkey/curve25519/donna.cpp +++ b/src/lib/pubkey/curve25519/donna.cpp @@ -350,9 +350,9 @@ cmult(limb *resultx, limb *resultz, const u8 *n, const limb *q) { copy_mem(nqpqx, q, 5); for (i = 0; i < 32; ++i) { - u8 byte = n[31 - i]; + u8 byteval = n[31 - i]; for (j = 0; j < 8; ++j) { - const limb bit = byte >> 7; + const limb bit = byteval >> 7; swap_conditional(nqx, nqpqx, bit); swap_conditional(nqz, nqpqz, bit); @@ -377,7 +377,7 @@ cmult(limb *resultx, limb *resultz, const u8 *n, const limb *q) { nqpqz = nqpqz2; nqpqz2 = t; - byte <<= 1; + byteval <<= 1; } } diff --git a/src/lib/pubkey/mce/polyn_gf2m.cpp b/src/lib/pubkey/mce/polyn_gf2m.cpp index 01a62da7d..a957b8cc1 100644 --- a/src/lib/pubkey/mce/polyn_gf2m.cpp +++ b/src/lib/pubkey/mce/polyn_gf2m.cpp @@ -647,16 +647,16 @@ polyn_gf2m::polyn_gf2m(int t, Botan::RandomNumberGenerator& rng, std::shared_ptr int i; (*this).set_coef( t, 1); i = 0; - int m_deg; + int degree = 0; do { for (i = 0; i < t; ++i) { (*this).set_coef( i, random_code_element(sp_field->get_cardinality(), rng)); } - polyn_gf2m::degppf(*this, &m_deg); + polyn_gf2m::degppf(*this, °ree); } - while (m_deg < t); + while (degree < t); } @@ -666,15 +666,15 @@ void polyn_gf2m::poly_shiftmod( const polyn_gf2m & g) { throw Invalid_Argument("shiftmod cannot be called on polynomials of degree 1 or less"); } - std::shared_ptr<GF2m_Field> msp_field = g.msp_field; + std::shared_ptr<GF2m_Field> field = g.msp_field; int t = g.get_degree(); - gf2m a = msp_field->gf_div(this->coeff[t-1], g.coeff[t]); + gf2m a = field->gf_div(this->coeff[t-1], g.coeff[t]); for (int i = t - 1; i > 0; --i) { this->coeff[i] = this->coeff[i - 1] ^ this->msp_field->gf_mul(a, g.coeff[i]); } - this->coeff[0] = msp_field->gf_mul(a, g.coeff[0]); + this->coeff[0] = field->gf_mul(a, g.coeff[0]); } std::vector<polyn_gf2m> polyn_gf2m::sqrt_mod_init(const polyn_gf2m & g) diff --git a/src/lib/tls/msg_certificate.cpp b/src/lib/tls/msg_certificate.cpp index f0ccc5328..5be9379bd 100644 --- a/src/lib/tls/msg_certificate.cpp +++ b/src/lib/tls/msg_certificate.cpp @@ -71,8 +71,10 @@ std::vector<byte> Certificate::serialize() const { std::vector<byte> raw_cert = m_certs[i].BER_encode(); const size_t cert_size = raw_cert.size(); - for(size_t i = 0; i != 3; ++i) - buf.push_back(get_byte<u32bit>(i+1, cert_size)); + for(size_t j = 0; j != 3; ++j) + { + buf.push_back(get_byte<u32bit>(j+1, cert_size)); + } buf += raw_cert; } |