~zooko/cryptopp/trunk

« back to all changes in this revision

Viewing changes to ida.cpp

  • Committer: weidai
  • Date: 2004-09-03 10:57:31 UTC
  • Revision ID: svn-v4:57ff6487-cd31-0410-9ec3-f628ee90f5f0:trunk/c5:193
changes related to the next FIPS validation

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
#include "algebra.h"
7
7
#include "gf2_32.h"
8
8
#include "polynomi.h"
9
 
#include <functional>
10
9
 
11
10
#include "polynomi.cpp"
12
11
 
66
65
                if (m_inputChannelIds.size() == m_threshold)
67
66
                        return m_threshold;
68
67
 
69
 
                m_lastMapPosition = m_inputChannelMap.insert(InputChannelMap::value_type(channelId, (unsigned int)m_inputChannelIds.size())).first;
 
68
                m_lastMapPosition = m_inputChannelMap.insert(pair<const unsigned long, unsigned int>(channelId, m_inputChannelIds.size())).first;
70
69
                m_inputQueues.push_back(MessageQueue());
71
70
                m_inputChannelIds.push_back(channelId);
72
71
 
85
84
                return it->second;
86
85
}
87
86
 
88
 
void RawIDA::ChannelData(word32 channelId, const byte *inString, size_t length, bool messageEnd)
 
87
void RawIDA::ChannelData(word32 channelId, const byte *inString, unsigned int length, bool messageEnd)
89
88
{
90
89
        int i = InsertInputChannel(channelId);
91
90
        if (i < m_threshold)
92
91
        {
93
 
                lword size = m_inputQueues[i].MaxRetrievable();
 
92
                unsigned long size = m_inputQueues[i].MaxRetrievable();
94
93
                m_inputQueues[i].Put(inString, length);
95
94
                if (size < 4 && size + length >= 4)
96
95
                {
117
116
        }
118
117
}
119
118
 
120
 
lword RawIDA::InputBuffered(word32 channelId) const
 
119
unsigned int RawIDA::InputBuffered(word32 channelId) const
121
120
{
122
121
        int i = LookupInputChannel(channelId);
123
122
        return i < m_threshold ? m_inputQueues[i].MaxRetrievable() : 0;
145
144
        m_outputChannelIdStrings.push_back(WordToString(channelId));
146
145
        m_outputQueues.push_back(ByteQueue());
147
146
        if (m_inputChannelIds.size() == m_threshold)
148
 
                ComputeV((unsigned int)m_outputChannelIds.size() - 1);
 
147
                ComputeV(m_outputChannelIds.size() - 1);
149
148
}
150
149
 
151
150
void RawIDA::PrepareInterpolation()
240
239
        m_ida.IsolatedInitialize(parameters);
241
240
}
242
241
 
243
 
size_t SecretSharing::Put2(const byte *begin, size_t length, int messageEnd, bool blocking)
 
242
unsigned int SecretSharing::Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking)
244
243
{
245
244
        if (!blocking)
246
245
                throw BlockingInputOnly("SecretSharing");
247
246
 
248
 
        SecByteBlock buf(UnsignedMin(256, length));
 
247
        SecByteBlock buf(STDMIN(length, 256U));
249
248
        unsigned int threshold = m_ida.GetThreshold();
250
249
        while (length > 0)
251
250
        {
252
 
                size_t len = STDMIN(length, buf.size());
 
251
                unsigned int len = STDMIN(length, (unsigned int)buf.size());
253
252
                m_ida.ChannelData(0xffffffff, begin, len, false);
254
253
                for (unsigned int i=0; i<threshold-1; i++)
255
254
                {
312
311
        m_ida.IsolatedInitialize(parameters);
313
312
}
314
313
 
315
 
size_t InformationDispersal::Put2(const byte *begin, size_t length, int messageEnd, bool blocking)
 
314
unsigned int InformationDispersal::Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking)
316
315
{
317
316
        if (!blocking)
318
317
                throw BlockingInputOnly("InformationDispersal");
370
369
                AttachedTransformation()->MessageEnd(GetAutoSignalPropagation()-1);
371
370
}
372
371
 
373
 
size_t PaddingRemover::Put2(const byte *begin, size_t length, int messageEnd, bool blocking)
 
372
unsigned int PaddingRemover::Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking)
374
373
{
375
374
        if (!blocking)
376
375
                throw BlockingInputOnly("PaddingRemover");
379
378
 
380
379
        if (m_possiblePadding)
381
380
        {
382
 
                size_t len = find_if(begin, end, bind2nd(not_equal_to<byte>(), 0)) - begin;
 
381
                unsigned int len = find_if(begin, end, bind2nd(not_equal_to<byte>(), 0)) - begin;
383
382
                m_zeroCount += len;
384
383
                begin += len;
385
384
                if (begin == end)