summaryrefslogtreecommitdiff
path: root/elgamal.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2005-07-12 04:23:32 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2005-07-12 04:23:32 +0000
commitd5ebf62bed594d1fe6ab616a6bbcbcf0a5892d47 (patch)
tree4b03760892a97a9bc452ebe8b7793bbebd402ad4 /elgamal.h
parentfa39f51809b4da54a5c2adb3e183b1a625cefb92 (diff)
downloadcryptopp-d5ebf62bed594d1fe6ab616a6bbcbcf0a5892d47.tar.gz
port to MSVC .NET 2005 beta 2
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@198 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'elgamal.h')
-rw-r--r--elgamal.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/elgamal.h b/elgamal.h
index 377d437..ef778ea 100644
--- a/elgamal.h
+++ b/elgamal.h
@@ -11,17 +11,17 @@ class CRYPTOPP_NO_VTABLE ElGamalBase : public DL_KeyAgreementAlgorithm_DH<Intege
public DL_SymmetricEncryptionAlgorithm
{
public:
- void Derive(const DL_GroupParameters<Integer> &groupParams, byte *derivedKey, unsigned int derivedLength, const Integer &agreedElement, const Integer &ephemeralPublicKey, const NameValuePairs &derivationParams) const
+ void Derive(const DL_GroupParameters<Integer> &groupParams, byte *derivedKey, size_t derivedLength, const Integer &agreedElement, const Integer &ephemeralPublicKey, const NameValuePairs &derivationParams) const
{
agreedElement.Encode(derivedKey, derivedLength);
}
- unsigned int GetSymmetricKeyLength(unsigned int plainTextLength) const
+ size_t GetSymmetricKeyLength(size_t plainTextLength) const
{
return GetGroupParameters().GetModulus().ByteCount();
}
- unsigned int GetSymmetricCiphertextLength(unsigned int plainTextLength) const
+ size_t GetSymmetricCiphertextLength(size_t plainTextLength) const
{
unsigned int len = GetGroupParameters().GetModulus().ByteCount();
if (plainTextLength <= GetMaxSymmetricPlaintextLength(len))
@@ -30,7 +30,7 @@ public:
return 0;
}
- unsigned int GetMaxSymmetricPlaintextLength(unsigned int cipherTextLength) const
+ size_t GetMaxSymmetricPlaintextLength(size_t cipherTextLength) const
{
unsigned int len = GetGroupParameters().GetModulus().ByteCount();
if (cipherTextLength == len)
@@ -39,7 +39,7 @@ public:
return 0;
}
- void SymmetricEncrypt(RandomNumberGenerator &rng, const byte *key, const byte *plainText, unsigned int plainTextLength, byte *cipherText, const NameValuePairs &parameters) const
+ void SymmetricEncrypt(RandomNumberGenerator &rng, const byte *key, const byte *plainText, size_t plainTextLength, byte *cipherText, const NameValuePairs &parameters) const
{
const Integer &p = GetGroupParameters().GetModulus();
unsigned int modulusLen = p.ByteCount();
@@ -47,12 +47,12 @@ public:
SecByteBlock block(modulusLen-1);
rng.GenerateBlock(block, modulusLen-2-plainTextLength);
memcpy(block+modulusLen-2-plainTextLength, plainText, plainTextLength);
- block[modulusLen-2] = plainTextLength;
+ block[modulusLen-2] = (byte)plainTextLength;
a_times_b_mod_c(Integer(key, modulusLen), Integer(block, modulusLen-1), p).Encode(cipherText, modulusLen);
}
- DecodingResult SymmetricDecrypt(const byte *key, const byte *cipherText, unsigned int cipherTextLength, byte *plainText, const NameValuePairs &parameters) const
+ DecodingResult SymmetricDecrypt(const byte *key, const byte *cipherText, size_t cipherTextLength, byte *plainText, const NameValuePairs &parameters) const
{
const Integer &p = GetGroupParameters().GetModulus();
unsigned int modulusLen = p.ByteCount();
@@ -78,8 +78,8 @@ template <class BASE, class SCHEME_OPTIONS, class KEY>
class ElGamalObjectImpl : public DL_ObjectImplBase<BASE, SCHEME_OPTIONS, KEY>, public ElGamalBase
{
public:
- unsigned int FixedMaxPlaintextLength() const {return MaxPlaintextLength(FixedCiphertextLength());}
- unsigned int FixedCiphertextLength() const {return this->CiphertextLength(0);}
+ size_t FixedMaxPlaintextLength() const {return MaxPlaintextLength(FixedCiphertextLength());}
+ size_t FixedCiphertextLength() const {return this->CiphertextLength(0);}
const DL_GroupParameters_GFP & GetGroupParameters() const {return this->GetKey().GetGroupParameters();}