summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2003-05-15 17:36:53 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2003-05-15 17:36:53 +0000
commitb2f2c1f2c534d20cd06aed7717b19b8ab101e254 (patch)
tree245eb257f93ee67df6f7112490a727077e5df3ee
parent180a6796fd546fdb4a4d26b6a3a815bca4db5645 (diff)
downloadcryptopp-b2f2c1f2c534d20cd06aed7717b19b8ab101e254.tar.gz
*** empty log message ***
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@67 57ff6487-cd31-0410-9ec3-f628ee90f5f0
-rw-r--r--cryptlib.h8
-rw-r--r--dsa.h2
-rw-r--r--queue.cpp49
-rw-r--r--test.cpp1
4 files changed, 30 insertions, 30 deletions
diff --git a/cryptlib.h b/cryptlib.h
index bdb281d..a1e57b8 100644
--- a/cryptlib.h
+++ b/cryptlib.h
@@ -1555,11 +1555,9 @@ public:
};
#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
-typedef PK_SignatureScheme PK_SignatureSystem
-typedef PK_SignatureSchemeWithRecovery PK_SignatureSystemWithRecovery
-typedef SimpleKeyAgreementDomain PK_SimpleKeyAgreementDomain
-typedef AuthenticatedKeyAgreementDomain PK_AuthenticatedKeyAgreementDomain
-typedef WithPrecomputation PK_WithPrecomputation
+typedef PK_SignatureScheme PK_SignatureSystem;
+typedef SimpleKeyAgreementDomain PK_SimpleKeyAgreementDomain;
+typedef AuthenticatedKeyAgreementDomain PK_AuthenticatedKeyAgreementDomain;
#endif
NAMESPACE_END
diff --git a/dsa.h b/dsa.h
index 8aa252c..0628b18 100644
--- a/dsa.h
+++ b/dsa.h
@@ -25,7 +25,7 @@ const int MIN_DSA_PRIME_LENGTH = DSA::MIN_PRIME_LENGTH;
const int MAX_DSA_PRIME_LENGTH = DSA::MAX_PRIME_LENGTH;
const int DSA_PRIME_LENGTH_MULTIPLE = DSA::PRIME_LENGTH_MULTIPLE;
-bool GenerateDSAPrimes(const byte *seed, unsigned int seedLength, int &counter, Integer &p, unsigned int primeLength, Integer &q)
+inline bool GenerateDSAPrimes(const byte *seed, unsigned int seedLength, int &counter, Integer &p, unsigned int primeLength, Integer &q)
{return DSA::GeneratePrimes(seed, seedLength, counter, p, primeLength, q);}
#endif
diff --git a/queue.cpp b/queue.cpp
index a01e213..8ef1141 100644
--- a/queue.cpp
+++ b/queue.cpp
@@ -34,19 +34,11 @@ public:
m_head = m_tail = 0;
}
-/* inline unsigned int Put(byte inByte)
- {
- if (MaxSize()==m_tail)
- return 0;
-
- buf[m_tail++]=inByte;
- return 1;
- }
-*/
inline unsigned int Put(const byte *begin, unsigned int length)
{
unsigned int l = STDMIN(length, MaxSize()-m_tail);
- memcpy(buf+m_tail, begin, l);
+ if (buf+m_tail != begin)
+ memcpy(buf+m_tail, begin, l);
m_tail += l;
return l;
}
@@ -166,9 +158,7 @@ ByteQueue::~ByteQueue()
void ByteQueue::Destroy()
{
- ByteQueueNode *next;
-
- for (ByteQueueNode *current=m_head; current; current=next)
+ for (ByteQueueNode *next, *current=m_head; current; current=next)
{
next=current->next;
delete current;
@@ -198,8 +188,15 @@ bool ByteQueue::IsEmpty() const
void ByteQueue::Clear()
{
- Destroy();
- m_head = m_tail = new ByteQueueNode(m_nodeSize);
+ for (ByteQueueNode *next, *current=m_head->next; current; current=next)
+ {
+ next=current->next;
+ delete current;
+ }
+
+ m_tail = m_head;
+ m_head->Clear();
+ m_head->next = NULL;
m_lazyLength = 0;
}
@@ -211,10 +208,10 @@ unsigned int ByteQueue::Put2(const byte *inString, unsigned int length, int mess
unsigned int len;
while ((len=m_tail->Put(inString, length)) < length)
{
- m_tail->next = new ByteQueueNode(m_nodeSize);
- m_tail = m_tail->next;
inString += len;
length -= len;
+ m_tail->next = new ByteQueueNode(STDMAX(m_nodeSize, STDMIN(length, 16U*1024U)));
+ m_tail = m_tail->next;
}
return 0;
@@ -346,11 +343,17 @@ void ByteQueue::Unget(byte inByte)
void ByteQueue::Unget(const byte *inString, unsigned int length)
{
- // TODO: make this more efficient
- ByteQueueNode *newHead = new ByteQueueNode(length);
- newHead->next = m_head;
- m_head = newHead;
- m_head->Put(inString, length);
+ unsigned int len = STDMIN(length, m_head->m_head);
+ memcpy(m_head->buf + m_head->m_head - len, inString + length - len, len);
+ length -= len;
+
+ if (length > 0)
+ {
+ ByteQueueNode *newHead = new ByteQueueNode(length);
+ newHead->next = m_head;
+ m_head = newHead;
+ m_head->Put(inString, length);
+ }
}
const byte * ByteQueue::Spy(unsigned int &contiguousSize) const
@@ -372,7 +375,7 @@ byte * ByteQueue::CreatePutSpace(unsigned int &size)
if (m_tail->m_tail == m_tail->MaxSize())
{
- m_tail->next = new ByteQueueNode(size < m_nodeSize ? m_nodeSize : STDMAX(m_nodeSize, 1024U));
+ m_tail->next = new ByteQueueNode(STDMAX(m_nodeSize, size));
m_tail = m_tail->next;
}
diff --git a/test.cpp b/test.cpp
index 640dece..63218f2 100644
--- a/test.cpp
+++ b/test.cpp
@@ -554,7 +554,6 @@ void RSASignFile(const char *privFilename, const char *messageFilename, const ch
{
FileSource privFile(privFilename, true, new HexDecoder);
RSASSA_PKCS1v15_SHA_Signer priv(privFile);
- // RSASSA_PKCS1v15_SHA_Signer ignores the rng. Use a real RNG for other signature schemes!
FileSource f(messageFilename, true, new SignerFilter(GlobalRNG(), priv, new HexEncoder(new FileSink(signatureFilename))));
}