On Tuesday, January 23, 2018 at 9:40:36 AM UTC-5, android4m3 wrote:
>
> Hi,
> can anyone help me how to generate a DSA private key with the sizes p=2048 
> and q=256 bits? It seems that the default for p=2048 is q=224 and I cannot 
> figure out how to create a key with the sizes I described.
>

You are having trouble because the typical way to generate a key hard codes 
224 for the subgroup size when the keysize is 2048. Also see 
https://github.com/weidai11/cryptopp/blob/master/gfpcrypt.cpp#L37 .

 https://www.cryptopp.com/wiki/Digital_Signature_Algorithm was missing an 
example, so we added the following. Here's how to side-step it.

$ cat test.cxx
#include "cryptlib.h"
#include "files.h"
#include "osrng.h"
#include "hex.h"
#include "dsa.h"

#include <iostream>
#include <cstdint>

int main(int argc, char* argv[])
{
    using namespace CryptoPP;
    AutoSeededRandomPool prng;

    AlgorithmParameters params = MakeParameters
        (Name::ModulusSize(), 2048, false)
        (Name::SubgroupOrderSize(), 256, false);

    DSA::PrivateKey privateKey;
    privateKey.GenerateRandom(prng, params);

    std::cout << "Test key: " << std::endl;
    HexEncoder hex(new FileSink(std::cout));
    privateKey.Save(hex);
    std::cout << std::endl;

    return 0;
}

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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to