X-Git-Url: https://git.syn-net.org/debian/?a=blobdiff_plain;f=src%2FkeyDerivation.cpp;h=25b7cf0b478309f0f5c71d80045dbe9b073cebd1;hb=28d7bdf54141384a0940ec092a530fa2779d92a0;hp=cdf6368fe44ccf9c90dd6abbe4b9c484a0aa2b9e;hpb=058ae090a970436caec3b3059e9e18b310dd6b0d;p=anytun.git diff --git a/src/keyDerivation.cpp b/src/keyDerivation.cpp index cdf6368..25b7cf0 100644 --- a/src/keyDerivation.cpp +++ b/src/keyDerivation.cpp @@ -11,14 +11,15 @@ * tunneling and relaying of packets of any protocol. * * - * Copyright (C) 2007-2008 Othmar Gsenger, Erwin Nindl, + * Copyright (C) 2007-2009 Othmar Gsenger, Erwin Nindl, * Christian Pointner * * This file is part of Anytun. * * Anytun is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. * * Anytun is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -41,6 +42,7 @@ #include #include #include +#include #ifndef NO_CRYPT #ifndef NO_PASSPHRASE @@ -77,7 +79,7 @@ void KeyDerivation::calcMasterKey(std::string passphrase, u_int16_t length) } #ifndef USE_SSL_CRYPTO - Buffer digest(gcry_md_get_algo_dlen(GCRY_MD_SHA256)); + Buffer digest(static_cast(gcry_md_get_algo_dlen(GCRY_MD_SHA256))); gcry_md_hash_buffer(GCRY_MD_SHA256, digest.getBuf(), passphrase.c_str(), passphrase.length()); #else Buffer digest(u_int32_t(SHA256_DIGEST_LENGTH)); @@ -85,7 +87,7 @@ void KeyDerivation::calcMasterKey(std::string passphrase, u_int16_t length) #endif master_key_.setLength(length); - memcpy(master_key_.getBuf(), &digest.getBuf()[digest.getLength() - master_key_.getLength()], master_key_.getLength()); + std::memcpy(master_key_.getBuf(), &digest.getBuf()[digest.getLength() - master_key_.getLength()], master_key_.getLength()); } void KeyDerivation::calcMasterSalt(std::string passphrase, u_int16_t length) @@ -106,7 +108,7 @@ void KeyDerivation::calcMasterSalt(std::string passphrase, u_int16_t length) } #ifndef USE_SSL_CRYPTO - Buffer digest(gcry_md_get_algo_dlen(GCRY_MD_SHA1)); + Buffer digest(static_cast(gcry_md_get_algo_dlen(GCRY_MD_SHA1))); gcry_md_hash_buffer(GCRY_MD_SHA1, digest.getBuf(), passphrase.c_str(), passphrase.length()); #else Buffer digest(u_int32_t(SHA_DIGEST_LENGTH)); @@ -114,7 +116,7 @@ void KeyDerivation::calcMasterSalt(std::string passphrase, u_int16_t length) #endif master_salt_.setLength(length); - memcpy(master_salt_.getBuf(), &digest.getBuf()[digest.getLength() - master_salt_.getLength()], master_salt_.getLength()); + std::memcpy(master_salt_.getBuf(), &digest.getBuf()[digest.getLength() - master_salt_.getLength()], master_salt_.getLength()); } #endif #endif @@ -287,7 +289,7 @@ bool AesIcmKeyDerivation::calcCtr(kd_dir_t dir, satp_prf_label_t label, seq_nr_t cLog.msg(Log::PRIO_ERROR) << "KeyDerivation::calcCtr: salt lengths don't match"; return false; } - memcpy(ctr_[dir].salt_.buf_, master_salt_.getBuf(), SALT_LENGTH); + std::memcpy(ctr_[dir].salt_.buf_, master_salt_.getBuf(), SALT_LENGTH); ctr_[dir].salt_.zero_ = 0; ctr_[dir].params_.label_ ^= SATP_PRF_LABEL_T_HTON(convertLabel(dir, label)); ctr_[dir].params_.seq_ ^= SEQ_NR_T_HTON(seq_nr);