Re: [cryptopp-users] Chunking a base64 encoded file

2018-04-04 Thread Jeffrey Walton
On Wed, Apr 4, 2018 at 4:32 PM,   wrote:
>
> Would Base64Decoder work gracefully with chunking? Looking at below code
> which I slapped together from the Wiki example on chunking and with Jeff's
> help re EndOfFile (which I just did not see above the screen and only tried
> to search for in the Wiki and source code), I have this question: once the
> MeterFilter starts slicing and dicing the input, and feeding to the
> Base64Decoder, would the later be smart enough to process successfully? It
> seems that from every 3 input bytes Base64Decoder has to recover 2 data
> bytes. Does it mean that chunk size for this scenario has to be a multiple
> of 3?
>
>
> MeterFilter meter;
> StreamTransformationFilter
> decryptorFilter((StreamTransformation&)decryptor);
> Base64Decoder base64Dec;
>
> FileSource source(sourceStream, false);
> FileSink sink(destStream);
>
> source.Attach(new Redirector(decryptorFilter));
> if (Base64Encode)
> {
> decryptorFilter.Attach(new Redirector(base64Dec));
> base64Dec.Attach(new Redirector(meter)); // meter filter
> feeding base64 decryptor? will this work?
> }
> else
> {
> decryptorFilter.Attach(new Redirector(meter));
> }
> meter.Attach(new Redirector(sink));
>
> word64 processed = 0;
>
> while (!FileUtil::EndOfFile(source) &&
> !source.SourceExhausted())
> {
> source.Pump(ChunkSize); // so hear we would have to
> adjust ChunkSize to the nearest greater multiple of 3?
> decryptorFilter.Flush(false);
>
> processed += ChunkSize;
>
> if (ProgressCallback != nullptr)
> {
> if (processed % (ProgressEvery) == 0)
> {
> ProgressCallback(meter.GetTotalBytes());
> }
> }
> }

What happens in reality is, you do this at the application layer:

source.Pump(ChunkSize);

You pump data into the attached
transformation/{encoder|encryptor|decoder|decryption|...} filter. The
filter then buffers your requests and flushes them at 4096 bytes or
when it gets a MessageEnd() signal.

I can't find the reference at the moment at the moment. When I do I'll
post it to the wiki page.

Jeff

Jeff

-- 
You received this message because you are subscribed to "Crypto++ Users". More 
information about Crypto++ and this group is available at 
http://www.cryptopp.com and 
http://groups.google.com/forum/#!forum/cryptopp-users.
--- 
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 cryptopp-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[cryptopp-users] Chunking a base64 encoded file

2018-04-04 Thread mahonheiser

Would Base64Decoder work gracefully with chunking? Looking at below code 
which I slapped together from the Wiki example on chunking and with Jeff's 
help re EndOfFile (which I just did not see above the screen and only tried 
to search for in the Wiki and source code), I have this question: once the 
MeterFilter starts slicing and dicing the input, and feeding to the 
Base64Decoder, would the later be smart enough to process successfully? It 
seems that from every 3 input bytes Base64Decoder has to recover 2 data 
bytes. Does it mean that chunk size for this scenario has to be a multiple 
of 3?


MeterFilter meter;
StreamTransformationFilter 
decryptorFilter((StreamTransformation&)decryptor);
Base64Decoder base64Dec;

FileSource source(sourceStream, false);
FileSink sink(destStream);

source.Attach(new Redirector(decryptorFilter));
if (Base64Encode)
{
decryptorFilter.Attach(new Redirector(base64Dec));
base64Dec.Attach(new Redirector(meter)); // meter 
filter feeding base64 decryptor? will this work?
}
else
{
decryptorFilter.Attach(new Redirector(meter));
}
meter.Attach(new Redirector(sink));

word64 processed = 0;

while (!FileUtil::EndOfFile(source) && 
!source.SourceExhausted())
{
source.Pump(ChunkSize); // so hear we would have to 
adjust ChunkSize to the nearest greater multiple of 3?
decryptorFilter.Flush(false);

processed += ChunkSize;

if (ProgressCallback != nullptr)
{
if (processed % (ProgressEvery) == 0)
{
ProgressCallback(meter.GetTotalBytes());
}
}
}



-- 
You received this message because you are subscribed to "Crypto++ Users". More 
information about Crypto++ and this group is available at 
http://www.cryptopp.com and 
http://groups.google.com/forum/#!forum/cryptopp-users.
--- 
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 cryptopp-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [cryptopp-users] PGP

2018-04-04 Thread mahonheiser
Jeff,

There is no mention of PGP in the roadmap on the Wiki (which is also 1 
version behind vs 6.2 mentioned in this group). Are there concrete plans 
for including the PGP scheme?
I am also very much interested in PGP support due to horrible memory 
management bestowed on Bouncy Castle by .NET and its mediocre performance. 
Crypto++ with its tiny memory footprint and portability is miles ahead of 
BC, and if it supported PGP OOB it would be a BC killer. And OpenGPG is a 
joke.

Mahon


On Tuesday, March 27, 2018 at 10:37:45 AM UTC-4, Jeffrey Walton wrote:
>
> On Tue, Mar 27, 2018 at 10:34 AM,   
> wrote: 
> > Does Crypto++ current version support decryption/encryption of PGP 
> files, 
> > created by other tools, such as Gpg4Win, BouncyCastle etc? 
> > If it does, are there any code examples or documentation on how to 
> interop 
> > with PGP? 
>
> Sorry, currently no. 
>
> I believe most of the pieces are available to do it. But the schemes 
> have not been incorporated into the library. 
>
> Jeff 
>

-- 
You received this message because you are subscribed to "Crypto++ Users". More 
information about Crypto++ and this group is available at 
http://www.cryptopp.com and 
http://groups.google.com/forum/#!forum/cryptopp-users.
--- 
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 cryptopp-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[cryptopp-users] Re: Base 64 URL Decoding Wtih Base64Decoder?

2018-04-04 Thread Jeffrey Walton


On Tuesday, April 3, 2018 at 11:46:00 PM UTC-4, hc12...@gmail.com wrote:
>
> Hi,
>
> I noticed that Base64URLDecoder exists but unfortunately, I am stuck with 
> 5.6.2, which doesn't have it.
>

It can be available in all versions of the library. Just copy/paste it from 
the existing sources :)
 

> So I followed the recommendation on 
> https://www.cryptopp.com/wiki/Base64Decoder (Changing Alphabets section):
>
> // my code snippet
> std::string decoded_key;
>
> const byte ALPHABET[] = 
> "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
> int lookup[256];
> CryptoPP::Base64Decoder::InitializeDecodingLookupArray(lookup, 
> ALPHABET, 64, false);
>
> try
> {
> CryptoPP::Base64Decoder* pDecoder = new 
> CryptoPP::Base64Decoder();
> 
> pDecoder->IsolatedInitialize(CryptoPP::MakeParameters(CryptoPP::Name::DecodingLookupArray(),(const
>  
> int *)lookup));
> pDecoder->Attach(new CryptoPP::StringSink(decoded_key));
> // Decode the key since it is base64url encoded
> CryptoPP::StringSource src(key, true, pDecoder);
>
>
> But then I got an exception:
> AlgorithmParametersBase: parameter "DecodingLookupArray" not used
>

Not sure why you are catching the exception but...

You can add false as a thid parameter to avoid the exception:

MakeParameters(Name::DecodingLookupArray(),(const int *)lookup), false);

I'm not sure what trouble you might encounter afterwards, like failure to 
change the alphabet or changing the alphabet for all decoders.

In the end, I recommend the copy/paste method to get it.

Jeff

-- 
You received this message because you are subscribed to "Crypto++ Users". More 
information about Crypto++ and this group is available at 
http://www.cryptopp.com and 
http://groups.google.com/forum/#!forum/cryptopp-users.
--- 
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 cryptopp-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[cryptopp-users] Re: Is there any other way to access this group than by having a Google account?

2018-04-04 Thread Jeffrey Walton


On Tuesday, April 3, 2018 at 6:04:47 PM UTC-4, mahon...@gmail.com wrote:
>
> Google groups is very inconvenient for me as I do no have a cellular phone 
> to which Google could send an SMS message. Most maillists can be accessed 
> by sending a subscribe email to a special address. Is there any way to 
> access this via email as well? After a day or two Google's bots will pick 
> out my account and shut it down as they cannot send me an SMS. So I would 
> have to keep registering for a brand new account every couple days. This is 
> a royal PITA.
>

No, we don't run a mailing list or Usenet group. I believe from the early 
1990s until about 2005 or 2010 Wei ran a group. I think it is was part of 
his Eskimo domain.

If I recall correctly, the project cut-over to Google Groups because it 
relieved us of admin and storage duties at no cost. It also increased 
availability. I still remember when Wei uploaded all of his messages to 
Google Groups.

An alternate may be 
https://www.mail-archive.com/cryptopp-users@googlegroups.com/ . 

Jeff

-- 
You received this message because you are subscribed to "Crypto++ Users". More 
information about Crypto++ and this group is available at 
http://www.cryptopp.com and 
http://groups.google.com/forum/#!forum/cryptopp-users.
--- 
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 cryptopp-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[cryptopp-users] Re: What is EndOfFile?

2018-04-04 Thread Jeffrey Walton


On Tuesday, April 3, 2018 at 6:01:07 PM UTC-4, mahon...@gmail.com wrote:
>
> There is a call to EndOfFile in the manually pumping example at 
> https://www.cryptopp.com/wiki/Pipelining
> Where is it defined?
>

EndOfFile is provided in the wiki example. It is not available in the 
Crypto++ sources.If you need it, just copy/paste it.

Keep in min that eof() is not set until you read beyond the end of the 
file. Also see https://stackoverflow.com/q/4533063/608639 .

Jeff


-- 
You received this message because you are subscribed to "Crypto++ Users". More 
information about Crypto++ and this group is available at 
http://www.cryptopp.com and 
http://groups.google.com/forum/#!forum/cryptopp-users.
--- 
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 cryptopp-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.