Am 17.10.2015 um 21:27 schrieb Jeffrey Walton:
>
>> Open question: should the class file respond to DiscardBytes? I
>> kinda feel like it should be a nop, but there could be folks who
>> want to call it to increase their comfort level.
> The promise of DiscardBytes() is, well, to discard bytes. If this
> actually makes sense from a security standpoint or efficiency
> stand point is not at us to judge, or we wouldn't have created
> this function in the first place. If the user wants to discard 500
> bytes, let him do this via DiscardBytes() or he'll just write
> DiscardBytes() himself.
>
>
> If I parsed this correctly, then you want DiscardBytes to perform the
> discard.
yes you did :)
>
> Here's the updated implementations. Its optimized for
> word/register-sized discards.
>
> //! generate and discard n bytes.
> void RDRAND::DiscardBytes(size_t n)
> {
> assert(Ready());
> #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32
> static const size_t SIZE = 128/sizeof(word64);
> FixedSizeSecBlock<word64, SIZE> discard;
> #else
> static const size_t SIZE = 128/sizeof(word32);
> FixedSizeSecBlock<word32, SIZE> discard;
> #endif
>
> size_t count = STDMIN(n, discard.SizeInBytes());
> while (count)
> {
> GenerateBlock(discard.BytePtr(), count);
> n -= count;
> count = STDMIN(n, discard.SizeInBytes());
> }
> }
Why not follow the standard implementation here and maybe optimize
GenerateIntoBufferedTransformation() instead?
//! generate and discard n bytes.
void RDRAND::DiscardBytes(size_t n)
{
assert(Ready());
GenerateIntoBufferedTransformation(TheBitBucket(), DEFAULT_CHANNEL, n);
}
BR
JPM
>
> GenerateBlock can throw, so callers will need to be aware of the
> potential side effects of the discard.
>
> Jeff
> --
> --
> 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]
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout.
--
--
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/d/optout.