I'm stuck on the last chunk of data. I've tried what seems like every
possible method to insure the mac is seen, The following code runs without
error but will decrypt with MAC Invalid error. Any help will be appreciated.


                                readchunk.clear();
                                readchunk.resize((size_t)lwRead);
                                sourcein->GetStream()->seekg(lastPos, 
std::ios::beg);
                                
sourcein->GetStream()->read((char*)readchunk.c_str(),
(std::streamsize)lwRead);

                                if(bFirst)
                                {       
                                        ef.ChannelPut( AAD_CHANNEL, (const 
byte*)aad_data.data(),
aad_data.size());
                                        ef.ChannelPut( DEFAULT_CHANNEL, 
(byte*)readchunk.data(), (size_t)lwRead
);
                                        //ef.ChannelMessageEnd(AAD_CHANNEL);
                                        bFirst = false;
                                }
                                else if(bLast)
                                {
                                        e.Resynchronize((byte *)iv.c_str(), 
(int)iv.length());
                                        //next ...
                                        e.SetKeyWithIV((byte*)key.c_str(), 
key.length(), (byte *)iv.c_str(),
iv.length());
                                        //next ...
                                        //e.SpecifyDataLengths(aad_data.size(), 
lwRead, 0);
                                        //e.Update((const 
byte*)aad_data.data(), aad_data.size());
                                        
                                        //or
                                        e.SpecifyDataLengths(0, lwRead, 0);
                                        e.Update(NULL, 0);

                                        ef.ChannelMessageEnd(AAD_CHANNEL);
                                        //or
                                        //e.SpecifyDataLengths(0, lwRead, 
0);//aad_data not needed?
                                        //e.Update(NULL, 0);

                                        //cipher.clear();
                                        //cipher.resize((unsigned int)lwRead);
                                        
//e.ProcessString((byte*)cipher.data(),(byte*)readchunk.data(), lwRead
);
                                        //or
                                        
//e.ProcessString((byte*)readchunk.data(), lwRead );
                                        
                                        //works after ProcessString
                                        //InitBytes4(mac);
                                        //e.TruncatedFinal(mac, TAG_SIZE);
                                        
                                        //next ...
                                        
ef.PutMessageEnd((byte*)readchunk.data(), (size_t)lwRead);
//e.ProcessString here instead???
                                        //or
                                        //ef.Put((byte*)readchunk.data(), 
(size_t)lwRead );//-TAG_SIZE
                                        //ef.MessageEnd();
                                }
                                else
                                        ef.Put((byte*)readchunk.data(), 
(size_t)lwRead );


                                maxRetrieve = ef.MaxRetrievable();
                                cipher.clear();
                                cipher.resize((unsigned int)maxRetrieve);
                                ef.Get((byte*)cipher.data(), 
(size_t)maxRetrieve );//+ TAG_SIZE

                                if(maxRetrieve != 0)
                                {
                                        
sinkout->GetStream()->write((char*)cipher.c_str(),
(std::streamsize)maxRetrieve);
                                        sinkout->IsolatedFlush( false, true ); 
                                }




--
View this message in context: 
http://crypto-users.996303.n3.nabble.com/CCM-multi-line-large-files-tp4831.html
Sent from the Crypto++ Users mailing list archive at Nabble.com.

-- 
-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to