summaryrefslogtreecommitdiff
path: root/seckey.h
diff options
context:
space:
mode:
authorweidai <weidai11@users.noreply.github.com>2005-07-12 04:23:32 +0000
committerweidai <weidai11@users.noreply.github.com>2005-07-12 04:23:32 +0000
commit1db8ea50840eb47f0f7d8f3c30d8e0916932ce90 (patch)
tree4b03760892a97a9bc452ebe8b7793bbebd402ad4 /seckey.h
parent31068bd68590654dc218bbb183a2ca71bb4af08b (diff)
downloadcryptopp-git-1db8ea50840eb47f0f7d8f3c30d8e0916932ce90.tar.gz
port to MSVC .NET 2005 beta 2
Diffstat (limited to 'seckey.h')
-rw-r--r--seckey.h50
1 files changed, 25 insertions, 25 deletions
diff --git a/seckey.h b/seckey.h
index bcbb8843..d7f90d24 100644
--- a/seckey.h
+++ b/seckey.h
@@ -35,13 +35,13 @@ public:
protected:
template <class T>
- static inline void CheckedSetKey(T *obj, CipherDir dir, const byte *key, unsigned int length, const NameValuePairs &param)
+ static inline void CheckedSetKey(T *obj, CipherDir dir, const byte *key, size_t length, const NameValuePairs &param)
{
obj->ThrowIfInvalidKeyLength(length);
int rounds = param.GetIntValueWithDefault("Rounds", ROUNDS);
if (rounds != ROUNDS)
throw InvalidRounds(obj->StaticAlgorithmName(), rounds);
- obj->UncheckedSetKey(dir, key, length);
+ obj->UncheckedSetKey(dir, key, (unsigned int)length);
}
};
@@ -51,7 +51,7 @@ class VariableRounds
{
public:
enum {DEFAULT_ROUNDS = D, MIN_ROUNDS = N, MAX_ROUNDS = M};
- static unsigned int StaticGetDefaultRounds(unsigned int keylength) {return DEFAULT_ROUNDS;}
+ static unsigned int StaticGetDefaultRounds(size_t keylength) {return DEFAULT_ROUNDS;}
protected:
static inline void AssertValidRounds(unsigned int rounds)
@@ -60,13 +60,13 @@ protected:
}
template <class T>
- static inline void CheckedSetKey(T *obj, CipherDir dir, const byte *key, unsigned int length, const NameValuePairs &param)
+ static inline void CheckedSetKey(T *obj, CipherDir dir, const byte *key, size_t length, const NameValuePairs &param)
{
obj->ThrowIfInvalidKeyLength(length);
int rounds = param.GetIntValueWithDefault("Rounds", obj->StaticGetDefaultRounds(length));
if (rounds < (int)MIN_ROUNDS || rounds > (int)MAX_ROUNDS)
throw InvalidRounds(obj->AlgorithmName(), rounds);
- obj->UncheckedSetKey(dir, key, length, rounds);
+ obj->UncheckedSetKey(dir, key, (unsigned int)length, rounds);
}
};
@@ -79,7 +79,7 @@ class FixedKeyLength
public:
enum {KEYLENGTH=N, MIN_KEYLENGTH=N, MAX_KEYLENGTH=N, DEFAULT_KEYLENGTH=N};
enum {IV_REQUIREMENT = IV_REQ};
- static unsigned int CRYPTOPP_API StaticGetValidKeyLength(unsigned int) {return KEYLENGTH;}
+ static size_t CRYPTOPP_API StaticGetValidKeyLength(size_t) {return KEYLENGTH;}
};
/// support query of variable key length, template parameters are default, min, max, multiple (default multiple 1)
@@ -96,12 +96,12 @@ class VariableKeyLength
public:
enum {MIN_KEYLENGTH=N, MAX_KEYLENGTH=M, DEFAULT_KEYLENGTH=D, KEYLENGTH_MULTIPLE=Q};
enum {IV_REQUIREMENT = IV_REQ};
- static unsigned int CRYPTOPP_API StaticGetValidKeyLength(unsigned int n)
+ static size_t CRYPTOPP_API StaticGetValidKeyLength(size_t n)
{
- if (n < (unsigned int)MIN_KEYLENGTH)
+ if (n < (size_t)MIN_KEYLENGTH)
return MIN_KEYLENGTH;
- else if (n > (unsigned int)MAX_KEYLENGTH)
- return (unsigned int)MAX_KEYLENGTH;
+ else if (n > (size_t)MAX_KEYLENGTH)
+ return (size_t)MAX_KEYLENGTH;
else
{
n += KEYLENGTH_MULTIPLE-1;
@@ -117,24 +117,24 @@ class SameKeyLengthAs
public:
enum {MIN_KEYLENGTH=T::MIN_KEYLENGTH, MAX_KEYLENGTH=T::MAX_KEYLENGTH, DEFAULT_KEYLENGTH=T::DEFAULT_KEYLENGTH};
enum {IV_REQUIREMENT = T::IV_REQUIREMENT};
- static unsigned int CRYPTOPP_API StaticGetValidKeyLength(unsigned int keylength)
+ static size_t CRYPTOPP_API StaticGetValidKeyLength(size_t keylength)
{return T::StaticGetValidKeyLength(keylength);}
};
// ************** implementation helper for SimpledKeyed ***************
template <class T>
-static inline void CheckedSetKey(T *obj, Empty empty, const byte *key, unsigned int length, const NameValuePairs &param)
+static inline void CheckedSetKey(T *obj, Empty empty, const byte *key, size_t length, const NameValuePairs &param)
{
obj->ThrowIfInvalidKeyLength(length);
- obj->UncheckedSetKey(key, length);
+ obj->UncheckedSetKey(key, (unsigned int)length);
}
template <class T>
-static inline void CheckedSetKey(T *obj, CipherDir dir, const byte *key, unsigned int length, const NameValuePairs &param)
+static inline void CheckedSetKey(T *obj, CipherDir dir, const byte *key, size_t length, const NameValuePairs &param)
{
obj->ThrowIfInvalidKeyLength(length);
- obj->UncheckedSetKey(dir, key, length);
+ obj->UncheckedSetKey(dir, key, (unsigned int)length);
}
//! _
@@ -142,14 +142,14 @@ template <class BASE, class INFO = BASE>
class CRYPTOPP_NO_VTABLE SimpleKeyingInterfaceImpl : public BASE
{
public:
- unsigned int MinKeyLength() const {return INFO::MIN_KEYLENGTH;}
- unsigned int MaxKeyLength() const {return (unsigned int)INFO::MAX_KEYLENGTH;}
- unsigned int DefaultKeyLength() const {return INFO::DEFAULT_KEYLENGTH;}
- unsigned int GetValidKeyLength(unsigned int n) const {return INFO::StaticGetValidKeyLength(n);}
+ size_t MinKeyLength() const {return INFO::MIN_KEYLENGTH;}
+ size_t MaxKeyLength() const {return (size_t)INFO::MAX_KEYLENGTH;}
+ size_t DefaultKeyLength() const {return INFO::DEFAULT_KEYLENGTH;}
+ size_t GetValidKeyLength(size_t n) const {return INFO::StaticGetValidKeyLength(n);}
typename BASE::IV_Requirement IVRequirement() const {return (typename BASE::IV_Requirement)INFO::IV_REQUIREMENT;}
protected:
- void AssertValidKeyLength(unsigned int length) {assert(GetValidKeyLength(length) == length);}
+ void AssertValidKeyLength(size_t length) {assert(GetValidKeyLength(length) == length);}
};
template <class INFO, class BASE = BlockCipher>
@@ -167,14 +167,14 @@ public:
BlockCipherFinal() {}
BlockCipherFinal(const byte *key)
{SetKey(key, this->DEFAULT_KEYLENGTH);}
- BlockCipherFinal(const byte *key, unsigned int length)
+ BlockCipherFinal(const byte *key, size_t length)
{SetKey(key, length);}
- BlockCipherFinal(const byte *key, unsigned int length, unsigned int rounds)
+ BlockCipherFinal(const byte *key, size_t length, unsigned int rounds)
{this->SetKeyWithRounds(key, length, rounds);}
bool IsForwardTransformation() const {return DIR == ENCRYPTION;}
- void SetKey(const byte *key, unsigned int length, const NameValuePairs &param = g_nullNameValuePairs)
+ void SetKey(const byte *key, size_t length, const NameValuePairs &param = g_nullNameValuePairs)
{
CheckedSetKey(this, DIR, key, length, param);
}
@@ -185,7 +185,7 @@ template <class BASE, class INFO = BASE>
class MessageAuthenticationCodeImpl : public AlgorithmImpl<SimpleKeyingInterfaceImpl<BASE, INFO>, INFO>
{
public:
- void SetKey(const byte *key, unsigned int length, const NameValuePairs &params = g_nullNameValuePairs)
+ void SetKey(const byte *key, size_t length, const NameValuePairs &params = g_nullNameValuePairs)
{
CheckedSetKey(this, Empty(), key, length, params);
}
@@ -199,7 +199,7 @@ public:
MessageAuthenticationCodeFinal() {}
MessageAuthenticationCodeFinal(const byte *key)
{SetKey(key, this->DEFAULT_KEYLENGTH);}
- MessageAuthenticationCodeFinal(const byte *key, unsigned int length)
+ MessageAuthenticationCodeFinal(const byte *key, size_t length)
{this->SetKey(key, length);}
};