void ContextImpl::setIdentity(const Certificate& cert) { if( ! cert.impl()->pkey() ) throw InvalidCertificate("invalid certificate"); if(_pkey) EVP_PKEY_free(_pkey); _pkey = 0; if(_x509) X509_free(_x509); _x509 = 0; _x509 = copyX509( cert.impl()->x509() ); _pkey = copyPrivateKey( cert.impl()->pkey() ); if( ! SSL_CTX_use_certificate(_ctx, _x509) ) { throw InvalidCertificate("invalid certificate"); } if( ! SSL_CTX_use_PrivateKey( _ctx, _pkey ) ) { throw InvalidCertificate("invalid certificate"); } // openssl will not check the private key of this context against the // certifictate. TO do so call SSL_CTX_check_private_key(_ctx) }
VanityGenPage::VanityGenPage(QWidget *parent, BitcoinGUI *_gui): QWidget(parent), gui(_gui), walletModel(0), ui(new Ui::VanityGenPage) { ui->setupUi(this); model = new QStandardItemModel(0,3,this); QStringList headerLabels; headerLabels << "Pattern" << "Privkey" << "Chance"; model->setHorizontalHeaderLabels(headerLabels); ui->tableView->setModel(model); ui->tableView->setAlternatingRowColors(true); ui->tableView->verticalHeader()->setVisible(false); ui->tableView->horizontalHeader()->setSectionResizeMode(1,QHeaderView::Stretch); ui->tableView->horizontalHeader()->resizeSection(0,250); ui->tableView->horizontalHeader()->resizeSection(2,150); ui->tableView->setSelectionMode(QAbstractItemView::ExtendedSelection);//MultiSelection); ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(tableViewClicked(QItemSelection,QItemSelection))); connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customMenuRequested(QPoint))); ui->tableView->setFocusPolicy(Qt::StrongFocus); ui->tableView->installEventFilter(this); VanityGenKeysChecked = 0; VanityGenHashrate = 0;//"0.0"; VanityGenNThreads = 0; VanityGenMatchCase = 0; //Input field: ui->lineEdit->setValidator(new QRegExpValidator(QRegExp("[S]{1,1}[MNP-Za-k]{1,1}[1-9A-HJ-NP-Za-km-z]{10,10}"), NULL)); ui->lineEdit->setMaxLength(16); connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(changeAllowedText())); connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(addPatternClicked())); checkAllowedText(0); //"Add Pattern" - Buttton: connect(ui->buttonPattern, SIGNAL(clicked()), this, SLOT(addPatternClicked())); int nThreads = boost::thread::hardware_concurrency(); int nUseThreads = GetArg("-genproclimit", -1); if (nUseThreads < 0) nUseThreads = nThreads; ui->horizontalSlider->setMaximum(nUseThreads); ui->checkBoxAutoImport->setEnabled(false); ui->buttonImport->setEnabled(false); ui->buttonDelete->setEnabled(false); connect(ui->checkBoxMatchCase, SIGNAL(clicked(bool)), this, SLOT(changeMatchCase(bool))); connect(ui->buttonDelete, SIGNAL(clicked(bool)),this, SLOT(deleteRows())); connect(ui->buttonImport, SIGNAL(clicked(bool)), this, SLOT(importIntoWallet())); connect(ui->horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(updateLabelNrThreads(int))); connect(ui->horizontalSlider, SIGNAL(sliderReleased()), this, SLOT(saveFile())); connect(ui->checkBoxAutoImport, SIGNAL(released()), this, SLOT(saveFile())); connect(ui->checkBoxShowPrivKeys, SIGNAL(released()), this, SLOT(saveFile())); connect(ui->buttonStart,SIGNAL(clicked()), this, SLOT(startThread())); connect(ui->buttonUnlock,SIGNAL(clicked()), this, SLOT(unlockWallet())); copyAddressAction = new QAction("Copy Address", this); copyPrivateKeyAction = new QAction("Copy PrivateKey", this); importIntoWalletAction = new QAction("Import into Wallet", this); deleteAction = new QAction("Delete", this); contextMenu = new QMenu(); contextMenu->addAction(importIntoWalletAction); contextMenu->addSeparator(); contextMenu->addAction(copyAddressAction); contextMenu->addAction(copyPrivateKeyAction); contextMenu->addSeparator(); contextMenu->addAction(deleteAction); connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress())); connect(copyPrivateKeyAction, SIGNAL(triggered()), this, SLOT(copyPrivateKey())); connect(importIntoWalletAction, SIGNAL(triggered()), this, SLOT(importIntoWallet())); connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteEntry())); QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(updateVanityGenUI())); timer->start(250); updateUi(); loadFile(); }
void ContextImpl::assign(const ContextImpl& ctx) { // TODO: consider to create a new SSL_CTX if required setProtocol(ctx._protocol); setVerifyMode(ctx._verify); setVerifyDepth(ctx._verifyDepth); // copy certificates presented to peer if(_pkey) EVP_PKEY_free(_pkey); _pkey = 0; if(_x509) X509_free(_x509); _x509 = 0; if( ctx._x509 ) { _pkey = copyPrivateKey( ctx._pkey ); _x509 = copyX509( ctx._x509 ); if( ! SSL_CTX_use_certificate(_ctx, _x509) ) { throw InvalidCertificate("invalid certificate"); } if( ! SSL_CTX_use_PrivateKey( _ctx, _pkey ) ) { throw InvalidCertificate("invalid certificate"); } } _extraCerts.clear(); _extraCerts.reserve( ctx._extraCerts.size() ); for(std::vector<X509*>::const_iterator it = ctx._extraCerts.begin(); it != ctx._extraCerts.end(); ++it) { // NOTE: SSL_CTX_add_extra_chain_cert does not copy the X509 certificate, // or increase the refcount. We must copy it, because the SSL_CTX will // free it X509* extraX509 = copyX509(*it); X509AutoPtr x509Ptr(extraX509); if( ! SSL_CTX_add_extra_chain_cert( _ctx, extraX509 ) ) throw InvalidCertificate("invalid extra certificate"); _extraCerts.push_back(extraX509); x509Ptr.release(); } // copy trusted CA certificates for(std::vector<X509*>::iterator it = _caCerts.begin(); it != _caCerts.end(); ++it) { X509_free(*it); } _caCerts.clear(); _caCerts.reserve( ctx._caCerts.size() ); X509_STORE* store = X509_STORE_new(); X509StoreAutoPtr storePtr(store); for(std::vector<X509*>::const_iterator it = ctx._caCerts.begin(); it != ctx._caCerts.end(); ++it) { X509* x509 = copyX509(*it); X509AutoPtr x509Ptr(x509); if( ! X509_STORE_add_cert(store, x509) ) throw InvalidCertificate("untrusted certificate"); _caCerts.push_back(x509); x509Ptr.release(); } SSL_CTX_set_cert_store( _ctx, store ); storePtr.release(); }