Hi to all, I am able to generate DSA 512 bit KeyPair using crypto++ using the following code bool CreateDSAKeys() { CryptoPP::AutoSeededX917RNG<CryptoPP::AES> prng; try { CryptoPP::GDSA<CryptoPP::SHA1>::GroupParameters pqg; pqg.GenerateRandom (prng, CryptoPP::MakeParameters(CryptoPP::Name::ModulusSize (), 512)(CryptoPP::Name::SubgroupOrderSize (), 160)); OutputData(output, "P ", pqg.GetModulus (), pqg.GetModulus ().ByteCount ()); OutputData(output, "Q ", pqg.GetSubgroupOrder(), pqg.GetSubgroupOrder ().ByteCount ()); OutputData(output, "G ", pqg.GetSubgroupGenerator(), pqg.GetSubgroupGenerator ().ByteCount ()); CryptoPP::GDSA<CryptoPP::SHA1>::Signer priv; priv.AccessKey().GenerateRandom(prng, pqg);//CryptoPP::MakeParameters(CryptoPP::Name::ModulusSize (), 512) /*CryptoPP::MakeParameters(CryptoPP::Name::ModulusSize(), 512)*/); DSA::Verifier pub(priv); OutputData(output, "X ", priv.GetKey().GetPrivateExponent(), priv.GetKey().GetPrivateExponent().ByteCount ()); OutputData(output, "Y ", pub.GetKey().GetPublicElement(), pub.GetKey().GetPublicElement().ByteCount ()); } }
But, The length of the PrivateKey x Parameter and the length of the Q parameter are not equal and the values of group parameters are also not constant. can any one suggest me a way to solve this problem. Thanks in advance.
IICTECH
Posts
-
How to generate DSA 512 bit KeyPair in VC++ 2010 -
How to execute java exe in VC++ 2010 ?I want to integrate java with c++. I already created java exe called
IKRYSignENC.exe
. I have to pass command line arguments to execute this exe. For that,I have used shellExecute as follows
ShellExecute (NULL, "open", "D:\\IKRYSignENC.exe", "D:\\NSRM3443\\Test\\ch21\\ENC_ROOT\\IN121MTM.000" "C:\\CASM_IKRYPT_JAVA\\Support\\Inputs\\CellKeys.txt" "D:\\", NULL, SW_SHOW);
It is compiling with out any errors, but while running it is giving the error like
Loaded 'D:\IKRYSignENC.exe', Binary was not built with debug information.
Unloaded 'D:\IKRYSignENC.exe'Can any one please suggest me the correct usage of shellExecute. :)
-
How to execute java exe in VC++ 2010 ?hi, I want to execute java exe by passing arguments in VC++ 2010. I have tried shellExecute, but it is not working. Can any one please help me. Thanks in advance. :)
-
how to get private key from a file (not from a keystore) to sign data ?My private key file is a text file and it contains the data
// BIG p
FCA6 82CE 8E12 CABA 26EF CCF7 110E 526D B078 B05E DECB CD1E B4A2 08F3 AE16 17AE 01F3 5B91 A47E 6DF6 3413 C5E1 2ED0 899B CD13 2ACD 50D9 9151 BDC4 3EE7 3759 2E17.
// BIG q
962E DDCC 369C BA8E BB26 0EE6 B6A1 26D9 346E 38C5.
// BIG g
6784 71B2 7A9C F44E E91A 49C5 147D B1A9 AAF2 44F0 5A43 4D64 8693 1D2D 1427 1B9E 3503 0B71 FD73 DA17 9069 B32E 2935 630E 1C20 6235 4D0D A20A 6C41 6E50 BE79 4CA4.
// BIG x
06CE 2BF2 3F33 FDCD 3F22 1301 4F56 1152 69F6 FA4D.Here BIG x is the private key and I need this key to sign my data. :)
-
how to get private key from a file (not from a keystore) to sign data ?Hi, I'm trying to sign data using dsa private key using openSSL. I want to use a private key that is stored in a file. Can any one please suggest me how to get privae key from a file. Thanks in advance. ;)
-
how to compress data using zlib?Hi All, Can any one help me out to work on zlib compression. Thanks in advance!
-
Exception:)
-
Exceptionhi all, how can v resolve "BigInteger not invertible." Exception?? can any one help!! Thanks!
-
How to convert byte array to hex stringHey im new to this forum stuff... well i could not locate the question i posted in the discussions.So i just re-posted it.. hope mistakes are accepted for the first time :-D by the way thanks for the reply.
-
How to convert byte array to hex stringHi All, I got a piece of code from google to convert byte array to hex string...i din't understand few lines of code can any on ehelp me to understand ?? :)
public static String CellKeysGeneration() { byte[] btba = new byte[5]; Random r = new Random(); r.nextBytes(btba); for (int i = 0; i < btba.length; i++) { btba[i] = btba[i]; } String str = tohexString(btba); return str; } public static String tohexString(byte[] bytes) { StringBuffer sb = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { sb.append(tohex(bytes[i] >> 4)); sb.append(tohex(bytes[i])); } return sb.toString(); } public static char tohex(int nibble) { final char[] hexdigit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E' , 'F' }; return hexdigit[nibble & 0xF]; }
In above three functions, 1) I dint understand why in toHex function we are always performing "and" operartion with 0xF. 2) I dint understand why in tohexString function we are performing ">>" operation with 4. Can any one help me to understand toHexString and toHex functions ?? :) Thanks in advance ! -
How to validate our signature with our public key?Hey, We found the solution i.e., we were trying to sign unencrypted file but we have to sign encrypted file. Now we are able to validate our signature with our own public key. :-O
-
while signing the same data multiple times does signature vary?Hey, We found the solution. While signing same data multiple times with the same key will produce different signatures. :)
-
while signing the same data multiple times does signature vary?I have a key pair(my own public key and private key). I have signed my data with my private key. when i am trying to sign same data multiple times with private key, its generarting different signatures like My Private Key : // BIG p FCA6 82CE 8E12 CABA 26EF CCF7 110E 526D B078 B05E DECB CD1E B4A2 08F3 AE16 17AE 01F3 5B91 A47E 6DF6 3413 C5E1 2ED0 899B CD13 2ACD 50D9 9151 BDC4 3EE7 3759 2E17. // BIG q 962E DDCC 369C BA8E BB26 0EE6 B6A1 26D9 346E 38C5. // BIG g 6784 71B2 7A9C F44E E91A 49C5 147D B1A9 AAF2 44F0 5A43 4D64 8693 1D2D 1427 1B9E 3503 0B71 FD73 DA17 9069 B32E 2935 630E 1C20 6235 4D0D A20A 6C41 6E50 BE79 4CA4. // BIG x 06CE 2BF2 3F33 FDCD 3F22 1301 4F56 1152 69F6 FA4D. In the above it uses the // BIG x 06CE 2BF2 3F33 FDCD 3F22 1301 4F56 1152 69F6 FA4D. parameter as private key to sign. Sign File when i have signed for the first time :
// Signature part R:
493C F96C F7DA D6A5 75A3 BC4C 4F30 50A8 6C48 B213.
// Signature part S:
3EDB 39C8 3711 3E68 13F0 C14D 1264 D189 4B6F 014E.Sign File when i have signed for the second time :
// Signature part R:
764E 5BC4 C7F7 B8BC 1A25 D4F3 A565 FCAE 47D9 8BC9.
// Signature part S:
29EF 30C4 6483 904D 9A6B 53A1 4550 AD5B A71C 33E5.Thanks in advance. :)
-
How to validate our signature with our public key?Hi All, [CODE] // Signature part R: 0B9E 77E7 6D7E EA87 4D6D F987 AE3C E6D7 5BCD FEFB. // Signature part S: 65A2 17FF 1596 2356 E3BA 4692 9478 AC79 D801 B337. // Signature part R: 8135 C560 7FC0 6F82 B886 FAEF 5158 C18C 2D79 17AB. // Signature part S: 28A8 4825 B530 DE20 C571 9CDB 76D0 9489 EB7D 3149. // BIG p FCA6 82CE 8E12 CABA 26EF CCF7 110E 526D B078 B05E DECB CD1E B4A2 08F3 AE16 17AE 01F3 5B91 A47E 6DF6 3413 C5E1 2ED0 899B CD13 2ACD 50D9 9151 BDC4 3EE7 3759 2E17. // BIG q 962E DDCC 369C BA8E BB26 0EE6 B6A1 26D9 346E 38C5. // BIG g 6784 71B2 7A9C F44E E91A 49C5 147D B1A9 AAF2 44F0 5A43 4D64 8693 1D2D 1427 1B9E 3503 0B71 FD73 DA17 9069 B32E 2935 630E 1C20 6235 4D0D A20A 6C41 6E50 BE79 4CA4. // BIG y 4436 34C0 5D1C B536 8026 142B 3D6D 09DA D3B1 CD2C F4E9 B7AD B618 5466 51FC 2D54 8EB1 2394 30F4 323F 7240 E55A D44C 380B 13FB 7978 B825 0B44 2BD5 0ED3 A58B 9E5F. [CODE] Above signature in the bold must be validated using below public key : [CODE] // BIG p FCA6 82CE 8E12 CABA 26EF CCF7 110E 526D B078 B05E DECB CD1E B4A2 08F3 AE16 17AE 01F3 5B91 A47E 6DF6 3413 C5E1 2ED0 899B CD13 2ACD 50D9 9151 BDC4 3EE7 3759 2E17. // BIG q 962E DDCC 369C BA8E BB26 0EE6 B6A1 26D9 346E 38C5. // BIG g 6784 71B2 7A9C F44E E91A 49C5 147D B1A9 AAF2 44F0 5A43 4D64 8693 1D2D 1427 1B9E 3503 0B71 FD73 DA17 9069 B32E 2935 630E 1C20 6235 4D0D A20A 6C41 6E50 BE79 4CA4. // BIG y 4436 34C0 5D1C B536 8026 142B 3D6D 09DA D3B1 CD2C F4E9 B7AD B618 5466 51FC 2D54 8EB1 2394 30F4 323F 7240 E55A D44C 380B 13FB 7978 B825 0B44 2BD5 0ED3 A58B 9E5F. [CODE] In the above BIG y is the public key and we must validate the signature with this public key(this signature will be different each time we sign). Can any one please suggest :)
-
while signing the same data multiple times does signature vary?Hi, Please any one suggest, while signing with the same key I'm getting different signature each time,I don't whether it is right? :confused: Thanks in advance :)