这篇教程C++ verifier函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中verifier函数的典型用法代码示例。如果您正苦于以下问题:C++ verifier函数的具体用法?C++ verifier怎么用?C++ verifier使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了verifier函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: pop_stack // Pop and return the top type on stack type array after verifying it // is assignable to type. inline VerificationType pop_stack(VerificationType type, TRAPS) { if (_stack_size != 0) { VerificationType top = _stack[_stack_size - 1]; bool subtype = type.is_assignable_from( top, verifier(), false, CHECK_(VerificationType::bogus_type())); if (subtype) { --_stack_size; return top; } } return pop_stack_ex(type, THREAD); }
开发者ID:sourcemirror,项目名称:jdk-9-hotspot,代码行数:14,
示例2: push_stack_2 inline void push_stack_2( VerificationType type1, VerificationType type2, TRAPS) { assert(type1.is_long() || type1.is_double(), "must be long/double"); assert(type2.is_long2() || type2.is_double2(), "must be long/double_2"); if (_stack_size >= _max_stack - 1) { verifier()->verify_error( ErrorContext::stack_overflow(_offset, this), "Operand stack overflow"); return; } _stack[_stack_size++] = type1; _stack[_stack_size++] = type2; }
开发者ID:stkaushal,项目名称:jdk8_tl,代码行数:13,
示例3: whileCase * DiableHumain::choisirUneCase() { int x, y; bool ok; Case * c; // l’utilisateur choisit un coup do { // l’utilisateur tape un coup cout << "Diable > x ? "; cin >> x; cout << "Diable > y ? "; cin >> y; // le programme verifie le coup if (ok=verifier(x,y)) c = maPartie->monDamier->mesCases[x-1][y-1]; } while (!ok); return c;}
开发者ID:Issam-Engineer,项目名称:tp4infoinsa,代码行数:16,
示例4: key/** Verify a Certificate Verify message*/bool Certificate_Verify::verify(const X509_Certificate& cert, const Handshake_State& state, const Policy& policy) const { std::unique_ptr<Public_Key> key(cert.subject_public_key()); policy.check_peer_key_acceptable(*key); std::pair<std::string, Signature_Format> format = state.parse_sig_format(*key.get(), m_hash_algo, m_sig_algo, true, policy); PK_Verifier verifier(*key, format.first, format.second); return verifier.verify_message(state.hash().get_contents(), m_signature); }
开发者ID:jurajsomorovsky,项目名称:botan,代码行数:19,
示例5: du_fichiervoid du_fichier(void){ int i,choix; info("Lecture des valeurs x[i] et y[i] à partir d'un fichier:"); info("Le fichier doit contenir un point par ligne comme suit:/n"); info("/tx[i]/ty[i]/n/t/tx[i+1]/ty[i+1]/n/t/t..."); ouvrir_fichier(); x = MALLOC(double,n); y = MALLOC(double,n); if((x == NULL) || (y == NULL)) { erreur("Impossible d/'allouer la mémoire pour x et y (dans du_fichier())"); perror("Description système de l/'erreur"); menu(); return; } for(i = 0; i < n; i ++) { fscanf(donnees,"%lf/t%lf/n",x+i,y+i); } fclose(donnees); if(verifier() == 0) { erreur("Les valeurs des xi ne sont pas deux a deux distinctes."); info("Vous pouvez :/n/t1 - Recommencer/n/t2 - Abandonner"); invite("Votre choix :"); scanf("%d",&choix); vider_stdin(); if(choix == 1) { du_fichier(); return; //plus rien à faire ici } else { // il abandonne menu(); return; } } menu();}
开发者ID:erickedji,项目名称:zinal,代码行数:47,
示例6: TEST // TODO: Verify that this test is actually working correctly and not just // spuriously passing. Have no reason to suspect test is wrong. It just // seems complex. TEST(ByteCodeInterpreter, OutOfOrderMatches) { ShardId c_numShards = 1; char const * text = "RankDown {" " Delta: 2," " Child: LoadRowJz {" " Row: Row(0, 0, 0, false)," " Child: AndRowJz {" " Row: Row(1, 0, 1, false)," " Child: AndRowJz {" " Row: Row(2, 0, 2, false)," " Child: Report {" " Child: " " }" " }" " }" " }" "}"; const Rank initialRank = 2; ByteCodeVerifier verifier(GetIndex(c_numShards), initialRank); verifier.DeclareRow("3"); verifier.DeclareRow("5"); verifier.DeclareRow("7"); for (auto iteration : verifier.GetIterations()) { const size_t slice = verifier.GetSliceNumber(iteration); const size_t offset = verifier.GetOffset(iteration); for (size_t i = 0; i < 4; ++i) { const uint64_t row0 = verifier.GetRowData(0, offset + i, slice); const uint64_t row1 = verifier.GetRowData(1, (offset + i) >> 1, slice); const uint64_t row2 = verifier.GetRowData(2, (offset + i) >> 2, slice); verifier.ExpectResult(row0 & row1 & row2, offset + i, slice); } } verifier.Verify(text); }
开发者ID:BitFunnel,项目名称:BitFunnel,代码行数:49,
示例7: cryptopp_test// TODO remove it // verify the signature using crypto++ verifierint cryptopp_test(ECPPoint Q, Integer r, Integer s, byte *message, unsigned message_length){ std::vector<byte> signature(64); r.Encode(signature.data(), 32); s.Encode(signature.data()+32, 32); ECDSA<ECP, SHA256>::PublicKey publicKey; publicKey.Initialize(ASN1::secp256k1(), Q); ECDSA<ECP, SHA256>::Signer signer; ECDSA<ECP, SHA256>::Verifier verifier(publicKey); bool result = verifier.VerifyMessage( message, message_length, signature.data(), 64); if(!result){ // cerr << "FAIL cryptopp" << endl; return 1; } return 0;}
开发者ID:crypto271,项目名称:SellingInformation,代码行数:20,
示例8: voidvoid MemChecker::verify(){ if (!needMemCheck()) { return; } ModuleLoader *loader = testcase->getLoader(); typedef void (*verify_t)(void); verify_t verifier = (verify_t)loader->findSymbol("verifyMemChecker"); verifier(); //delete info; // Note: this will cause linux run exception //delete failure; //info = 0; //failure = 0;}
开发者ID:aprovy,项目名称:test-ng-pp,代码行数:18,
示例9: verifier/*** Verify a Server Key Exchange message*/bool Server_Key_Exchange::verify(const Public_Key& server_key, const Handshake_State& state, const Policy& policy) const { policy.check_peer_key_acceptable(server_key); std::pair<std::string, Signature_Format> format = state.parse_sig_format(server_key, m_hash_algo, m_sig_algo, false, policy); PK_Verifier verifier(server_key, format.first, format.second); verifier.update(state.client_hello()->random()); verifier.update(state.server_hello()->random()); verifier.update(params()); return verifier.check_signature(m_signature); }
开发者ID:jurajsomorovsky,项目名称:botan,代码行数:21,
示例10: get_req_binTest::ResultPK_Signature_Verification_Test::run_one_test(const std::string&, const VarMap& vars) { const std::vector<uint8_t> message = get_req_bin(vars, "Msg"); const std::vector<uint8_t> signature = get_req_bin(vars, "Signature"); const std::string padding = get_opt_str(vars, "Padding", default_padding(vars)); std::unique_ptr<Botan::Public_Key> pubkey = load_public_key(vars); Test::Result result(algo_name() + "/" + padding + " signature verification"); Botan::PK_Verifier verifier(*pubkey, padding); result.test_eq("correct signature valid", verifier.verify_message(message, signature), true); check_invalid_signatures(result, verifier, message, signature); return result; }
开发者ID:Chaosvex,项目名称:botan,代码行数:18,
示例11: QGroupBoxvoid Inscription::confirmation(){ grbConfirm = new QGroupBox("Confirmation", this); hboxConfirm = new QHBoxLayout(this); grbConfirm->setLayout(hboxConfirm); btnConfirmConfirmer = new QPushButton("Confirmer", this); hboxConfirm->addWidget(btnConfirmConfirmer); connect(btnConfirmConfirmer, SIGNAL(clicked()), this, SLOT(confirmer())); btnConfirmVerifier = new QPushButton("Vérifier", this); hboxConfirm->addWidget(btnConfirmVerifier); connect(btnConfirmVerifier, SIGNAL(clicked()), this, SLOT(verifier())); btnConfirmSortir = new QPushButton("Sortir", this); hboxConfirm->addWidget(btnConfirmSortir); connect(btnConfirmSortir, SIGNAL(clicked()), this, SLOT(quitter())); vboxMain->addWidget(grbConfirm);}
开发者ID:ArchSirius,项目名称:inf1010,代码行数:19,
示例12: assertvoid InvertibleRSAFunction::GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg){ int modulusSize = 2048; alg.GetIntValue(Name::ModulusSize(), modulusSize) || alg.GetIntValue(Name::KeySize(), modulusSize); assert(modulusSize >= 16); if (modulusSize < 16) throw InvalidArgument("InvertibleRSAFunction: specified modulus size is too small"); m_e = alg.GetValueWithDefault(Name::PublicExponent(), Integer(17)); assert(m_e >= 3); assert(!m_e.IsEven()); if (m_e < 3 || m_e.IsEven()) throw InvalidArgument("InvertibleRSAFunction: invalid public exponent"); RSAPrimeSelector selector(m_e); AlgorithmParameters primeParam = MakeParametersForTwoPrimesOfEqualSize(modulusSize) (Name::PointerToPrimeSelector(), selector.GetSelectorPointer()); m_p.GenerateRandom(rng, primeParam); m_q.GenerateRandom(rng, primeParam); m_d = m_e.InverseMod(LCM(m_p-1, m_q-1)); assert(m_d.IsPositive()); m_dp = m_d % (m_p-1); m_dq = m_d % (m_q-1); m_n = m_p * m_q; m_u = m_q.InverseMod(m_p); if (FIPS_140_2_ComplianceEnabled()) { RSASS<PKCS1v15, SHA>::Signer signer(*this); RSASS<PKCS1v15, SHA>::Verifier verifier(signer); SignaturePairwiseConsistencyTest_FIPS_140_Only(signer, verifier); RSAES<OAEP<SHA> >::Decryptor decryptor(*this); RSAES<OAEP<SHA> >::Encryptor encryptor(decryptor); EncryptionPairwiseConsistencyTest_FIPS_140_Only(encryptor, decryptor); }}
开发者ID:BreakoutCoin,项目名称:Breakout-Chain-Client,代码行数:40,
示例13: verifiervoid CLispEng::Verify(CObMap& obMap) { CVerifier verifier(obMap); /*!!! { //!!! for (int i=0; i<m_consMan.m_size; i++) { CConsValue *p = m_consMan.m_pBase+i; if (*(byte*)p != 0xFF) { if (Type(p->m_cdr) == TS_FRAME_PTR) Throw(E_FAIL); } } }*/ for (size_t i=0; i<m_packageMan.m_size; ++i) { CPackage *pack = m_packageMan.Base+i; if (*(byte*)pack != 0xFF) { CVerifyCallback c = { &verifier }; pack->m_mapSym.ForEachSymbolValue(c); } }}
开发者ID:ufasoft,项目名称:lisp,代码行数:22,
示例14: switchboolIsotropicBallModel::doParse(type::ModelCmdType cmd, std::list<std::string>& tokens){ if (tokens.empty()) return false; switch (cmd) { case type::MODEL_SET_TIME: case type::MODEL_SET_PHI: case type::MODEL_SET_THETA: case type::MODEL_SET_CATALOG_TYPE: { return IsotropicSphereModel::doParse(cmd, tokens); } case type::MODEL_SET_RADIUS: { SyntaxVerifier verifier(tokens); if (!verifier.verifyRange()) { std::stringstream ss; ss << "Parsing failed. Model '" << ModelMapper::instance()->getKey(getType()) << "'. Command '" << ModelCmdMapper::instance()->getKey(cmd) << "' requires range format."; Exception exc(type::EXCEPTION_WARNING + type::EXCEPTION_MOD_NO_PREFIX, ss.str(), PRETTY_FUNCTION); throw exc; } _minValue = std::strtod(verifier.getExtracted()[0]->c_str(), 0); _maxValue = std::strtod(verifier.getExtracted()[1]->c_str(), 0); tokens.clear(); return true; } default: break; } return false;}
开发者ID:NuclearReSerge,项目名称:grb,代码行数:38,
示例15: key/** Verify a Certificate Verify message*/bool Certificate_Verify::verify(const X509_Certificate& cert, const Handshake_State& state, const Policy& policy) const { std::unique_ptr<Public_Key> key(cert.subject_public_key()); policy.check_peer_key_acceptable(*key); std::pair<std::string, Signature_Format> format = state.parse_sig_format(*key.get(), m_hash_algo, m_sig_algo, true, policy); PK_Verifier verifier(*key, format.first, format.second); const bool signature_valid = verifier.verify_message(state.hash().get_contents(), m_signature);#if defined(BOTAN_UNSAFE_FUZZER_MODE) return true;#else return signature_valid;#endif }
开发者ID:Hackmanit,项目名称:botan,代码行数:26,
示例16: TEST TEST(NativeCode, AndRowJzMatches) { ShardId c_numShards = 1; char const * text = "LoadRowJz {" " Row: Row(0, 0, 0, false)," " Child: AndRowJz {" " Row: Row(1, 0, 0, false)," " Child: AndRowJz {" " Row: Row(2, 0, 0, false)," " Child: Report {" " Child: " " }" " }" " }" "}"; const Rank initialRank = 0; NativeCodeVerifier verifier(GetIndex(c_numShards), initialRank); verifier.DeclareRow("2"); verifier.DeclareRow("3"); verifier.DeclareRow("5"); for (auto iteration : verifier.GetIterations()) { const size_t slice = verifier.GetSliceNumber(iteration); const size_t offset = verifier.GetOffset(iteration); const uint64_t row0 = verifier.GetRowData(0, offset, slice); const uint64_t row1 = verifier.GetRowData(1, offset, slice); const uint64_t row2 = verifier.GetRowData(2, offset, slice); verifier.ExpectResult(row0 & row1 & row2, offset, slice); } verifier.Verify(text); }
开发者ID:BitFunnel,项目名称:BitFunnel,代码行数:37,
示例17: assertbool StackMapFrame::has_flag_match_exception( const StackMapFrame* target) const { // We allow flags of {UninitThis} to assign to {} if-and-only-if the // target frame does not depend upon the current type. // This is slightly too strict, as we need only enforce that the // slots that were initialized by the <init> (the things that were // UninitializedThis before initialize_object() converted them) are unused. // However we didn't save that information so we'll enforce this upon // anything that might have been initialized. This is a rare situation // and javac never generates code that would end up here, but some profilers // (such as NetBeans) might, when adding exception handlers in <init> // methods to cover the invokespecial instruction. See 7020118. assert(max_locals() == target->max_locals() && stack_size() == target->stack_size(), "StackMap sizes must match"); VerificationType top = VerificationType::top_type(); VerificationType this_type = verifier()->current_type(); if (!flag_this_uninit() || target->flags() != 0) { return false; } for (int i = 0; i < target->locals_size(); ++i) { if (locals()[i] == this_type && target->locals()[i] != top) { return false; } } for (int i = 0; i < target->stack_size(); ++i) { if (stack()[i] == this_type && target->stack()[i] != top) { return false; } } return true;}
开发者ID:4T-Shirt,项目名称:OpenJDK-Research,代码行数:37,
示例18: mainint main(){ int nombreutilisateur,nombreverifie,nombrealeatoire; bool victoire=false; int compteur=0,rejouer; nombrealeatoire = alea(1,10000); while(victoire==false){ nombreutilisateur = demander(); print_newline(); print_newline(); nombreverifie = verifier(nombreutilisateur); victoire = comparer(nombreverifie,nombrealeatoire); compteur = compteur+1;} print_text("Vous avez trouvé la solution en "); print_int(compteur); print_text(" coups"); print_newline(); print_newline(); print_text("Voulez vous rejouer ? : Oui ? tapez(1), Non ? tapez (2) : "); print_newline(); print_newline(); rejouer=read_int(); if(rejouer==1){main();} else{print_text("Au revoir !"); print_newline();print_newline();} return 0;}
开发者ID:MaximeDouylliez,项目名称:DUT-Info,代码行数:37,
示例19: ValidateESIGNbool ValidateESIGN(){ cout << "/nESIGN validation suite running.../n/n"; bool pass = true, fail; static const char plain[] = "test"; static const byte signature[] = "/xA3/xE3/x20/x65/xDE/xDA/xE7/xEC/x05/xC1/xBF/xCD/x25/x79/x7D/x99/xCD/xD5/x73/x9D/x9D/xF3/xA4/xAA/x9A/xA4/x5A/xC8/x23/x3D/x0D/x37/xFE/xBC/x76/x3F/xF1/x84/xF6/x59" "/x14/x91/x4F/x0C/x34/x1B/xAE/x9A/x5C/x2E/x2E/x38/x08/x78/x77/xCB/xDC/x3C/x7E/xA0/x34/x44/x5B/x0F/x67/xD9/x35/x2A/x79/x47/x1A/x52/x37/x71/xDB/x12/x67/xC1/xB6/xC6" "/x66/x73/xB3/x40/x2E/xD6/xF2/x1A/x84/x0A/xB6/x7B/x0F/xEB/x8B/x88/xAB/x33/xDD/xE4/x83/x21/x90/x63/x2D/x51/x2A/xB1/x6F/xAB/xA7/x5C/xFD/x77/x99/xF2/xE1/xEF/x67/x1A" "/x74/x02/x37/x0E/xED/x0A/x06/xAD/xF4/x15/x65/xB8/xE1/xD1/x45/xAE/x39/x19/xB4/xFF/x5D/xF1/x45/x7B/xE0/xFE/x72/xED/x11/x92/x8F/x61/x41/x4F/x02/x00/xF2/x76/x6F/x7C" "/x79/xA2/xE5/x52/x20/x5D/x97/x5E/xFE/x39/xAE/x21/x10/xFB/x35/xF4/x80/x81/x41/x13/xDD/xE8/x5F/xCA/x1E/x4F/xF8/x9B/xB2/x68/xFB/x28"; FileSource keys("TestData/esig1536.dat", true, new HexDecoder); ESIGN<SHA>::Signer signer(keys); ESIGN<SHA>::Verifier verifier(signer); fail = !SignatureValidate(signer, verifier); pass = pass && !fail; fail = !verifier.VerifyMessage((byte *)plain, strlen(plain), signature, verifier.SignatureLength()); pass = pass && !fail; cout << (fail ? "FAILED " : "passed "); cout << "verification check against test vector/n"; cout << "Generating signature key from seed..." << endl; signer.AccessKey().GenerateRandom(GlobalRNG(), MakeParameters("Seed", ConstByteArrayParameter((const byte *)"test", 4))("KeySize", 3*512)); verifier = signer; fail = !SignatureValidate(signer, verifier); pass = pass && !fail; return pass;}
开发者ID:hovatterz,项目名称:cryptopp,代码行数:36,
示例20: key/*** Verify a Certificate Verify message*/bool Certificate_Verify::verify(const X509_Certificate& cert, HandshakeHash& hash) { // FIXME: duplicate of Server_Key_Exchange::verify std::auto_ptr<Public_Key> key(cert.subject_public_key()); std::string padding = ""; Signature_Format format = IEEE_1363; if(key->algo_name() == "RSA") padding = "EMSA3(TLS.Digest.0)"; else if(key->algo_name() == "DSA") { padding == "EMSA1(SHA-1)"; format = DER_SEQUENCE; } else throw Invalid_Argument(key->algo_name() + " is invalid/unknown for TLS signatures"); PK_Verifier verifier(*key, padding, format); return verifier.verify_message(hash.final(), signature); }
开发者ID:relonger,项目名称:ECryptoLib,代码行数:27,
示例21: TestSignatureSchemevoid TestSignatureScheme(TestData &v){ std::string name = GetRequiredDatum(v, "Name"); std::string test = GetRequiredDatum(v, "Test"); member_ptr<PK_Signer> signer(ObjectFactoryRegistry<PK_Signer>::Registry().CreateObject(name.c_str())); member_ptr<PK_Verifier> verifier(ObjectFactoryRegistry<PK_Verifier>::Registry().CreateObject(name.c_str())); TestDataNameValuePairs pairs(v); if (test == "GenerateKey") { signer->AccessPrivateKey().GenerateRandom(GlobalRNG(), pairs); verifier->AccessPublicKey().AssignFrom(signer->AccessPrivateKey()); } else { std::string keyFormat = GetRequiredDatum(v, "KeyFormat"); if (keyFormat == "DER") verifier->AccessMaterial().Load(StringStore(GetDecodedDatum(v, "PublicKey")).Ref()); else if (keyFormat == "Component") verifier->AccessMaterial().AssignFrom(pairs); if (test == "Verify" || test == "NotVerify") { VerifierFilter verifierFilter(*verifier, NULL, VerifierFilter::SIGNATURE_AT_BEGIN); PutDecodedDatumInto(v, "Signature", verifierFilter); PutDecodedDatumInto(v, "Message", verifierFilter); verifierFilter.MessageEnd(); if (verifierFilter.GetLastResult() == (test == "NotVerify")) SignalTestFailure(); return; } else if (test == "PublicKeyValid") { if (!verifier->GetMaterial().Validate(GlobalRNG(), 3)) SignalTestFailure(); return; } if (keyFormat == "DER") signer->AccessMaterial().Load(StringStore(GetDecodedDatum(v, "PrivateKey")).Ref()); else if (keyFormat == "Component") signer->AccessMaterial().AssignFrom(pairs); } if (test == "GenerateKey" || test == "KeyPairValidAndConsistent") { TestKeyPairValidAndConsistent(verifier->AccessMaterial(), signer->GetMaterial()); VerifierFilter verifierFilter(*verifier, NULL, VerifierFilter::THROW_EXCEPTION); verifierFilter.Put((const byte *)"abc", 3); StringSource ss("abc", true, new SignerFilter(GlobalRNG(), *signer, new Redirector(verifierFilter))); } else if (test == "Sign") { SignerFilter f(GlobalRNG(), *signer, new HexEncoder(new FileSink(cout))); StringSource ss(GetDecodedDatum(v, "Message"), true, new Redirector(f)); SignalTestFailure(); } else if (test == "DeterministicSign") { // This test is specialized for RFC 6979. The RFC is a drop-in replacement // for DSA and ECDSA, and access to the seed or secret is not needed. If // additional determinsitic signatures are added, then the test harness will // likely need to be extended. string signature; SignerFilter f(GlobalRNG(), *signer, new HexEncoder(new StringSink(signature))); StringSource ss(GetDecodedDatum(v, "Message"), true, new Redirector(f)); if (GetDecodedDatum(v, "Signature") != signature) SignalTestFailure(); return; } else if (test == "RandomSign") { SignalTestError(); assert(false); // TODO: implement } else { SignalTestError(); assert(false); }}
开发者ID:Kthulhu,项目名称:cryptopp,代码行数:84,
示例22: TestSignatureSchemevoid TestSignatureScheme(TestData &v){ std::string name = GetRequiredDatum(v, "Name"); std::string test = GetRequiredDatum(v, "Test"); std::auto_ptr<PK_Signer> signer(ObjectFactoryRegistry<PK_Signer>::Registry().CreateObject(name.c_str())); std::auto_ptr<PK_Verifier> verifier(ObjectFactoryRegistry<PK_Verifier>::Registry().CreateObject(name.c_str())); TestDataNameValuePairs pairs(v); std::string keyFormat = GetRequiredDatum(v, "KeyFormat"); if (keyFormat == "DER") verifier->AccessMaterial().Load(StringStore(GetDecodedDatum(v, "PublicKey")).Ref()); else if (keyFormat == "Component") verifier->AccessMaterial().AssignFrom(pairs); if (test == "Verify" || test == "NotVerify") { VerifierFilter verifierFilter(*verifier, NULL, VerifierFilter::SIGNATURE_AT_BEGIN); PutDecodedDatumInto(v, "Signature", verifierFilter); PutDecodedDatumInto(v, "Message", verifierFilter); verifierFilter.MessageEnd(); if (verifierFilter.GetLastResult() == (test == "NotVerify")) SignalTestFailure(); } else if (test == "PublicKeyValid") { if (!verifier->GetMaterial().Validate(GlobalRNG(), 3)) SignalTestFailure(); } else goto privateKeyTests; return;privateKeyTests: if (keyFormat == "DER") signer->AccessMaterial().Load(StringStore(GetDecodedDatum(v, "PrivateKey")).Ref()); else if (keyFormat == "Component") signer->AccessMaterial().AssignFrom(pairs); if (test == "KeyPairValidAndConsistent") { TestKeyPairValidAndConsistent(verifier->AccessMaterial(), signer->GetMaterial()); } else if (test == "Sign") { SignerFilter f(GlobalRNG(), *signer, new HexEncoder(new FileSink(cout))); StringSource ss(GetDecodedDatum(v, "Message"), true, new Redirector(f)); SignalTestFailure(); } else if (test == "DeterministicSign") { SignalTestError(); assert(false); // TODO: implement } else if (test == "RandomSign") { SignalTestError(); assert(false); // TODO: implement } else if (test == "GenerateKey") { SignalTestError(); assert(false); } else { SignalTestError(); assert(false); }}
开发者ID:gogo40,项目名称:GoGo40-keygen,代码行数:72,
示例23: FIPS140_SampleApplication//.........这里部分代码省略......... abort(); } cout << "3. DES-EDE3-CFB Encryption/decryption succeeded./n"; // hash const byte message[] = {'a', 'b', 'c'}; const byte expectedDigest[] = {0xA9,0x99,0x3E,0x36,0x47,0x06,0x81,0x6A,0xBA,0x3E,0x25,0x71,0x78,0x50,0xC2,0x6C,0x9C,0xD0,0xD8,0x9D}; byte digest[20]; SHA1 sha; sha.Update(message, 3); sha.Final(digest); if (memcmp(digest, expectedDigest, 20) != 0) { cerr << "SHA-1 hash failed./n"; abort(); } cout << "4. SHA-1 hash succeeded./n"; // create auto-seeded X9.17 RNG object, if available#ifdef OS_RNG_AVAILABLE AutoSeededX917RNG<DES_EDE3> rng;#else // this is used to allow this function to compile on platforms that don't have auto-seeded RNGs RandomNumberGenerator &rng(NullRNG());#endif // generate DSA key DSA::PrivateKey dsaPrivateKey; dsaPrivateKey.GenerateRandomWithKeySize(rng, 1024); DSA::PublicKey dsaPublicKey; dsaPublicKey.AssignFrom(dsaPrivateKey); if (!dsaPrivateKey.Validate(rng, 3) || !dsaPublicKey.Validate(rng, 3)) { cerr << "DSA key generation failed./n"; abort(); } cout << "5. DSA key generation succeeded./n"; // encode DSA key std::string encodedDsaPublicKey, encodedDsaPrivateKey; dsaPublicKey.DEREncode(StringSink(encodedDsaPublicKey).Ref()); dsaPrivateKey.DEREncode(StringSink(encodedDsaPrivateKey).Ref()); // decode DSA key DSA::PrivateKey decodedDsaPrivateKey; decodedDsaPrivateKey.BERDecode(StringStore(encodedDsaPrivateKey).Ref()); DSA::PublicKey decodedDsaPublicKey; decodedDsaPublicKey.BERDecode(StringStore(encodedDsaPublicKey).Ref()); if (!decodedDsaPrivateKey.Validate(rng, 3) || !decodedDsaPublicKey.Validate(rng, 3)) { cerr << "DSA key encode/decode failed./n"; abort(); } cout << "6. DSA key encode/decode succeeded./n"; // sign and verify byte signature[40]; DSA::Signer signer(dsaPrivateKey); assert(signer.SignatureLength() == 40); signer.SignMessage(rng, message, 3, signature); DSA::Verifier verifier(dsaPublicKey); if (!verifier.VerifyMessage(message, 3, signature, sizeof(signature))) { cerr << "DSA signature and verification failed./n"; abort(); } cout << "7. DSA signature and verification succeeded./n"; // try to verify an invalid signature signature[0] ^= 1; if (verifier.VerifyMessage(message, 3, signature, sizeof(signature))) { cerr << "DSA signature verification failed to detect bad signature./n"; abort(); } cout << "8. DSA signature verification successfully detected bad signature./n"; // try to use an invalid key length try { ECB_Mode<DES_EDE3>::Encryption encryption_DES_EDE3_ECB; encryption_DES_EDE3_ECB.SetKey(key, 5); // should not be here cerr << "DES-EDE3 implementation did not detect use of invalid key length./n"; abort(); } catch (InvalidArgument &e) { cout << "9. Caught expected exception when using invalid key length. Exception message follows: "; cout << e.what() << endl; } cout << "/nFIPS 140-2 Sample Application completed normally./n";}
开发者ID:zooko,项目名称:cryptopp,代码行数:101,
示例24: verifiervoid code_heap::verify_all_blocks_set(){ all_blocks_set_verifier verifier(&all_blocks); allocator->iterate(verifier);}
开发者ID:mcandre,项目名称:factor,代码行数:5,
示例25: AvmAssert void MethodInfo::verify(Toplevel *toplevel, AbcEnv* abc_env) { AvmAssert(declaringTraits()->isResolved()); resolveSignature(toplevel); AvmCore* core = this->pool()->core; if (isNative()) { union { GprMethodProc implGPR; AvmThunkNativeThunker thunker; AvmThunkNativeThunkerN thunkerN; } u; #ifdef DEBUGGER if (core->debugger()) { MethodSignaturep ms = getMethodSignature(); if (ms->returnTraitsBT() == BUILTIN_number) u.thunkerN = MethodInfo::debugEnterExitWrapperN; else u.thunker = MethodInfo::debugEnterExitWrapper32; } else #endif { u.thunker = this->thunker(); } this->setNativeImpl(u.implGPR); } else { #ifdef DEBUGGER // just a fake CallStackNode here, so that if we throw a verify error, // we get a stack trace with the method being verified as its top entry. CallStackNode callStackNode(this); #endif /* DEBUGGER */ PERFM_NTPROF("verify-ticks"); CodeWriter* coder = NULL; Verifier verifier(this, toplevel, abc_env); /* These "buf" declarations are an unfortunate but expedient hack: the existing CodeWriter classes (eg CodegenLIR, etc) have historically always been stack-allocated, thus they have no WB protection on member fields. Recent changes were made to allow for explicit cleanup() of them in the event of exception, but there was a latent bug waiting to happen: the actual automatic var was going out of scope, but still being referenced (via the 'coder' pointer) in the exception handler, but the area being pointed to may or may not still be valid. The ideal fix for this would simply be to heap-allocate the CodeWriters, but that would require going thru the existing code carefully and inserting WB where appropriate. Instead, this "expedient" hack uses placement new to ensure the memory stays valid into the exception handler. Note: the lack of a call to the dtor of the CodeWriter(s) is not an oversight. Calling cleanup() on coder is equivalent to running the dtor for all of the CodeWriters here. Note: allocated using arrays of intptr_t (rather than char) to ensure alignment is acceptable. */ #define MAKE_BUF(name, type) / intptr_t name[(sizeof(type)+sizeof(intptr_t)-1)/sizeof(intptr_t)] #if defined FEATURE_NANOJIT MAKE_BUF(jit_buf, CodegenLIR); #if defined AVMPLUS_WORD_CODE MAKE_BUF(teeWriter_buf, TeeWriter); #endif #ifdef FEATURE_CFGWRITER MAKE_BUF(cfg_buf, CFGWriter); #endif #endif #if defined AVMPLUS_WORD_CODE MAKE_BUF(translator_buf, WordcodeEmitter); #else MAKE_BUF(stubWriter_buf, CodeWriter); #endif TRY(core, kCatchAction_Rethrow) {#if defined FEATURE_NANOJIT if ((core->IsJITEnabled()) && !suggestInterp()) { PERFM_NTPROF("verify & IR gen"); // note placement-new usage! CodegenLIR* jit = new(jit_buf) CodegenLIR(this); #if defined AVMPLUS_WORD_CODE WordcodeEmitter* translator = new(translator_buf) WordcodeEmitter(this, toplevel); TeeWriter* teeWriter = new(teeWriter_buf) TeeWriter(translator, jit); coder = teeWriter; #else coder = jit; #endif #ifdef FEATURE_CFGWRITER // analyze code and generate LIR CFGWriter* cfg = new(cfg_buf) CFGWriter(this, coder); coder = cfg;//.........这里部分代码省略.........
开发者ID:Jeffxz,项目名称:nodeas,代码行数:101,
注:本文中的verifier函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ verify函数代码示例 C++ verbprintf函数代码示例 |