void ZipArch::test() { clearShellOutput(); TDEProcess *kp = m_currentProcess = new TDEProcess; kp->clearArguments(); *kp << m_unarchiver_program << "-t"; if ( !m_password.isEmpty() ) *kp << "-P" << m_password; *kp << m_filename; connect( kp, SIGNAL( receivedStdout(TDEProcess*, char*, int) ), SLOT( slotReceivedOutput(TDEProcess*, char*, int) ) ); connect( kp, SIGNAL( receivedStderr(TDEProcess*, char*, int) ), SLOT( slotReceivedOutput(TDEProcess*, char*, int) ) ); connect( kp, SIGNAL( processExited(TDEProcess*) ), SLOT( slotTestExited(TDEProcess*) ) ); if ( !kp->start( TDEProcess::NotifyOnExit, TDEProcess::AllOutput ) ) { KMessageBox::error( 0, i18n( "Could not start a subprocess." ) ); emit sigTest( false ); } }
static int doTest( CSSM_CSP_HANDLE cspHand, CSSM_ALGORITHMS keyAlg, // RSA/DSA CSSM_ALGORITHMS sigAlg, unsigned sigLoops, // may be zero unsigned encrLoops, // ditto; it will be zero for DSA CSSM_BOOL rsaBlinding, CSSM_DATA_PTR ptext, unsigned maxPtextSize, uint32 keySizeInBits, // 0 --> random per alg CSSM_BOOL pubRefKeys, CSSM_BOOL privRefKeys, CSSM_BOOL bareCsp, // for other workarounds CSSM_BOOL quiet, CSSM_BOOL verbose) { CSSM_KEY cdsaGenPubKey; CSSM_KEY cdsaGenPrivKey; // only used to create bsafeDerivePrivKey CSSM_KEY cdsaTempKey; // raw key if privRefKeys true CSSM_KEY cdsaDerivePrivKey; // same as bsafeGenPrivKey BU_KEY bsafeGenPubKey; BU_KEY bsafeGenPrivKey; // only used to create cdsaDerivePrivKey BU_KEY bsafeDerivePrivKey; // same as cdsaGenPrivKey unsigned actKeySizeBits; CSSM_RETURN crtn; int rtn; if(!keySizeInBits) { /* random key size */ actKeySizeBits = randKeySizeBits(keyAlg, OT_Encrypt); } else { /* caller/user specified */ actKeySizeBits = keySizeInBits; } if(verbose) { printf(" ...generating %s key pair, keySize %d bits...\n", algToStr(keyAlg), actKeySizeBits); } /* * Generate two keypairs */ if(keyAlg == CSSM_ALGID_DSA) { CSSM_BOOL doGenParams; if(bareCsp || CSPDL_DSA_GEN_PARAMS) { doGenParams = CSSM_TRUE; } else { /* CSPDL - no gen params */ doGenParams = CSSM_FALSE; } crtn = cspGenDSAKeyPair(cspHand, "foo", 3, actKeySizeBits, &cdsaGenPubKey, pubRefKeys, CSSM_KEYUSE_ANY, CSSM_KEYBLOB_RAW_FORMAT_NONE, &cdsaGenPrivKey, privRefKeys, CSSM_KEYUSE_SIGN, CSSM_KEYBLOB_RAW_FORMAT_NONE, doGenParams, // genParams NULL); // params } else { crtn = cspGenKeyPair(cspHand, keyAlg, "foo", 3, actKeySizeBits, &cdsaGenPubKey, pubRefKeys, CSSM_KEYUSE_ANY, CSSM_KEYBLOB_RAW_FORMAT_NONE, &cdsaGenPrivKey, privRefKeys, CSSM_KEYUSE_ANY, CSSM_KEYBLOB_RAW_FORMAT_NONE, CSSM_FALSE); // genSeed not used } if(crtn) { return testError(quiet); } crtn = buGenKeyPair(actKeySizeBits, keyAlg, &bsafeGenPubKey, &bsafeGenPrivKey); if(crtn) { return testError(quiet); } /* * Convert private keys to other library. * NOTE: the reason we're only converting private keys is solely due to the * fact that BSAFE does not handle PKCS1 formatted public key blobs. Very odd. * But it's too much of a pain to re-implement that wheel here, and SSL and * cert handling in general verify the CSP's PKCS1-style public key handling. */ if(privRefKeys) { /* first generate a temporary raw CDSA key */ crtn = buBsafePrivKeyToCdsa(keyAlg, actKeySizeBits, bsafeGenPrivKey, &cdsaTempKey); if(crtn) { return testError(quiet); } /* convert it to the ref key we'll actually use */ crtn = cspRawKeyToRef(cspHand, &cdsaTempKey, &cdsaDerivePrivKey); cspFreeKey(cspHand, &cdsaTempKey); } else { crtn = buBsafePrivKeyToCdsa(keyAlg, actKeySizeBits, bsafeGenPrivKey, &cdsaDerivePrivKey); } if(crtn) { return testError(quiet); } if(privRefKeys) { /* we have a CDSA priv ref key; convert it to raw format */ crtn = cspRefKeyToRaw(cspHand, &cdsaGenPrivKey, &cdsaTempKey); if(crtn) { return testError(quiet); } /* now convert it to BSAFE */ crtn = buCdsaPrivKeyToBsafe(&cdsaTempKey, &bsafeDerivePrivKey); cspFreeKey(cspHand, &cdsaTempKey); } else { crtn = buCdsaPrivKeyToBsafe(&cdsaGenPrivKey, &bsafeDerivePrivKey); } if(crtn) { return testError(quiet); } if(sigLoops) { rtn = sigTest(cspHand, sigLoops, bsafeDerivePrivKey, &cdsaGenPubKey, &cdsaDerivePrivKey, bsafeGenPubKey, ptext, maxPtextSize, sigAlg, rsaBlinding, quiet, verbose); if(rtn) { return rtn; } } if(encrLoops) { rtn = encryptTest(cspHand, encrLoops, bsafeDerivePrivKey, &cdsaGenPubKey, &cdsaDerivePrivKey, bsafeGenPubKey, ptext, maxPtextSize, rsaBlinding, quiet, verbose); if(rtn) { return rtn; } } /* free all six keys */ buFreeKey(bsafeGenPubKey); buFreeKey(bsafeGenPrivKey); buFreeKey(bsafeDerivePrivKey); cspFreeKey(cspHand, &cdsaGenPubKey); cspFreeKey(cspHand, &cdsaGenPrivKey); cspFreeKey(cspHand, &cdsaDerivePrivKey); return 0; }