本文整理汇总了C++中Extensions类的典型用法代码示例。如果您正苦于以下问题:C++ Extensions类的具体用法?C++ Extensions怎么用?C++ Extensions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Extensions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: value
/*
* Handle attributes in a PKCS #10 request
*/
void PKCS10_Request::handle_attribute(const Attribute& attr)
{
BER_Decoder value(attr.parameters);
if(attr.oid == OIDS::lookup("PKCS9.EmailAddress"))
{
ASN1_String email;
value.decode(email);
m_info.add("RFC822", email.value());
}
else if(attr.oid == OIDS::lookup("PKCS9.ChallengePassword"))
{
ASN1_String challenge_password;
value.decode(challenge_password);
m_info.add("PKCS9.ChallengePassword", challenge_password.value());
}
else if(attr.oid == OIDS::lookup("PKCS9.ExtensionRequest"))
{
Extensions extensions;
value.decode(extensions).verify_end();
Data_Store issuer_info;
extensions.contents_to(m_info, issuer_info);
}
}
示例2: registerExtensions
void registerExtensions (Extensions& extensions)
{
extensions.registerInstruction ("user1", "", opcodeUser1);
extensions.registerInstruction ("user2", "", opcodeUser2);
extensions.registerInstruction ("user3", "", opcodeUser3, opcodeUser3);
extensions.registerInstruction ("user4", "", opcodeUser4, opcodeUser4);
}
示例3: PrefWidget
PrefAssociations::PrefAssociations(QWidget * parent, Qt::WindowFlags f)
: PrefWidget(parent, f )
{
setupUi(this);
connect(selectAll, SIGNAL(clicked(bool)), this, SLOT(selectAllClicked(bool)));
connect(selectNone, SIGNAL(clicked(bool)), this, SLOT(selectNoneClicked(bool)));
connect(listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(listItemClicked(QListWidgetItem*)));
connect(listWidget, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(listItemPressed(QListWidgetItem*)));
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
{
//Hide Select None - One cannot restore an association in Vista. Go figure.
selectNone->hide();
//QPushButton* lpbButton = new QPushButton("Launch Program Defaults", this);
//hboxLayout->addWidget(lpbButton);
//connect(lpbButton, SIGNAL(clicked(bool)), this, SLOT(launchAppDefaults()));
}
Extensions e;
for (int n=0; n < e.multimedia().count(); n++) {
addItem( e.multimedia()[n] );
}
// Add the playlist extensions
for (int n=0; n < e.playlist().count(); n++) {
addItem( e.playlist()[n] );
}
retranslateStrings();
something_changed = false;
}
示例4: throw
const Codec::Extensions* OggCodec::getExtensions() const throw()
{
static Extensions ext;
if (ext.empty() == 0) {
ext.push_back(".ogg");
}
return &ext;
}
示例5: encode_into
/*
* DER encode a CRL_Entry
*/
void CRL_Entry::encode_into(DER_Encoder& der) const
{
Extensions extensions;
extensions.add(new Cert_Extension::CRL_ReasonCode(reason));
der.start_cons(SEQUENCE)
.encode(BigInt::decode(serial, serial.size()))
.encode(time)
.encode(extensions)
.end_cons();
}
示例6: getExtensions
void PixelBufferObject::compileBuffer(State& state) const
{
unsigned int contextID = state.getContextID();
_compiledList[contextID] = 1;
osg::Image* image = _bufferEntryImagePair.second;
_bufferEntryImagePair.first.modifiedCount[contextID] = image->getModifiedCount();
if (!image->valid()) return;
Extensions* extensions = getExtensions(contextID,true);
GLuint& pbo = buffer(contextID);
if (pbo==0)
{
// building for the first time.
_totalSize = image->getTotalSizeInBytes();
// don't generate buffer if size is zero.
if (_totalSize==0) return;
extensions->glGenBuffers(1, &pbo);
extensions->glBindBuffer(_target, pbo);
extensions->glBufferData(_target, _totalSize, NULL, _usage);
}
else
{
extensions->glBindBuffer(_target, pbo);
if (_totalSize != image->getTotalSizeInBytes())
{
// resize PBO.
_totalSize = image->getTotalSizeInBytes();
extensions->glBufferData(_target, _totalSize, NULL, _usage);
}
}
// osg::Timer_t start_tick = osg::Timer::instance()->tick();
void* pboMemory = extensions->glMapBuffer(_target,
GL_WRITE_ONLY_ARB);
// copy data across
memcpy(pboMemory, image->data(), _totalSize);
// Unmap the texture image buffer
extensions->glUnmapBuffer(_target);
_bufferEntryImagePair.first.modifiedCount[contextID] = image->getModifiedCount();
// osg::notify(osg::NOTICE)<<"pbo _totalSize="<<_totalSize<<std::endl;
// osg::notify(osg::NOTICE)<<"pbo "<<osg::Timer::instance()->delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<<std::endl;
}
示例7: timespec_to_u32bit
/*
* Create a CRL
*/
X509_CRL X509_CA::make_crl(const std::vector<CRL_Entry>& revoked,
u32bit crl_number, u32bit next_update,
RandomNumberGenerator& rng) const
{
const size_t X509_CRL_VERSION = 2;
if(next_update == 0)
next_update = timespec_to_u32bit("7d");
// Totally stupid: ties encoding logic to the return of std::time!!
auto current_time = std::chrono::system_clock::now();
auto expire_time = current_time + std::chrono::seconds(next_update);
Extensions extensions;
extensions.add(
new Cert_Extension::Authority_Key_ID(m_cert.subject_key_id()));
extensions.add(new Cert_Extension::CRL_Number(crl_number));
// clang-format off
const std::vector<byte> crl = X509_Object::make_signed(
m_signer, rng, m_ca_sig_algo,
DER_Encoder().start_cons(SEQUENCE)
.encode(X509_CRL_VERSION-1)
.encode(m_ca_sig_algo)
.encode(m_cert.issuer_dn())
.encode(X509_Time(current_time))
.encode(X509_Time(expire_time))
.encode_if(revoked.size() > 0,
DER_Encoder()
.start_cons(SEQUENCE)
.encode_list(revoked)
.end_cons()
)
.start_explicit(0)
.start_cons(SEQUENCE)
.encode(extensions)
.end_cons()
.end_explicit()
.end_cons()
.get_contents());
// clang-format on
return X509_CRL(crl);
}
示例8: create_cert_req
/*
* Create a PKCS #10 certificate request
*/
PKCS10_Request create_cert_req(const X509_Cert_Options& opts,
const Private_Key& key,
const std::string& hash_fn,
RandomNumberGenerator& rng)
{
X509_DN subject_dn;
AlternativeName subject_alt;
load_info(opts, subject_dn, subject_alt);
Key_Constraints constraints;
if(opts.is_CA)
{
constraints = Key_Constraints(KEY_CERT_SIGN | CRL_SIGN);
}
else
{
verify_cert_constraints_valid_for_key_type(key, opts.constraints);
constraints = opts.constraints;
}
Extensions extensions = opts.extensions;
extensions.add_new(new Cert_Extension::Basic_Constraints(opts.is_CA, opts.path_limit));
if(constraints != NO_CONSTRAINTS)
{
extensions.add_new(new Cert_Extension::Key_Usage(constraints));
}
extensions.add_new(new Cert_Extension::Extended_Key_Usage(opts.ex_constraints));
extensions.add_new(new Cert_Extension::Subject_Alternative_Name(subject_alt));
return PKCS10_Request::create(key,
subject_dn,
extensions,
hash_fn,
rng,
opts.padding_scheme,
opts.challenge);
}
示例9: create_self_signed_cert
/*
* Create a new self-signed X.509 certificate
*/
X509_Certificate create_self_signed_cert(const X509_Cert_Options& opts,
const Private_Key& key,
const std::string& hash_fn,
RandomNumberGenerator& rng)
{
AlgorithmIdentifier sig_algo;
X509_DN subject_dn;
AlternativeName subject_alt;
// for now, only the padding option is used
std::map<std::string,std::string> sig_opts = { {"padding",opts.padding_scheme} };
const std::vector<uint8_t> pub_key = X509::BER_encode(key);
std::unique_ptr<PK_Signer> signer(choose_sig_format(key, sig_opts, rng, hash_fn, sig_algo));
load_info(opts, subject_dn, subject_alt);
Extensions extensions = opts.extensions;
Key_Constraints constraints;
if(opts.is_CA)
{
constraints = Key_Constraints(KEY_CERT_SIGN | CRL_SIGN);
}
else
{
verify_cert_constraints_valid_for_key_type(key, opts.constraints);
constraints = opts.constraints;
}
extensions.add_new(
new Cert_Extension::Basic_Constraints(opts.is_CA, opts.path_limit),
true);
if(constraints != NO_CONSTRAINTS)
{
extensions.add_new(new Cert_Extension::Key_Usage(constraints), true);
}
std::unique_ptr<Cert_Extension::Subject_Key_ID> skid(new Cert_Extension::Subject_Key_ID(pub_key, hash_fn));
extensions.add_new(new Cert_Extension::Authority_Key_ID(skid->get_key_id()));
extensions.add_new(skid.release());
extensions.add_new(
new Cert_Extension::Subject_Alternative_Name(subject_alt));
extensions.add_new(
new Cert_Extension::Extended_Key_Usage(opts.ex_constraints));
return X509_CA::make_cert(signer.get(), rng, sig_algo, pub_key,
opts.start, opts.end,
subject_dn, subject_dn,
extensions);
}
示例10: create_self_signed_cert
/*
* Create a new self-signed X.509 certificate
*/
X509_Certificate create_self_signed_cert(const X509_Cert_Options& opts,
const Private_Key& key,
const std::string& hash_fn,
RandomNumberGenerator& rng)
{
AlgorithmIdentifier sig_algo;
X509_DN subject_dn;
AlternativeName subject_alt;
std::vector<byte> pub_key = X509::BER_encode(key);
std::unique_ptr<PK_Signer> signer(choose_sig_format(key, hash_fn, sig_algo));
load_info(opts, subject_dn, subject_alt);
Key_Constraints constraints;
if(opts.is_CA)
{
constraints = Key_Constraints(KEY_CERT_SIGN | CRL_SIGN);
}
else
{
verify_cert_constraints_valid_for_key_type(key, opts.constraints);
constraints = opts.constraints;
}
Extensions extensions;
extensions.add(
new Cert_Extension::Basic_Constraints(opts.is_CA, opts.path_limit),
true);
if(constraints != NO_CONSTRAINTS)
{
extensions.add(new Cert_Extension::Key_Usage(constraints), true);
}
extensions.add(new Cert_Extension::Subject_Key_ID(pub_key));
extensions.add(
new Cert_Extension::Subject_Alternative_Name(subject_alt));
extensions.add(
new Cert_Extension::Extended_Key_Usage(opts.ex_constraints));
return X509_CA::make_cert(signer.get(), rng, sig_algo, pub_key,
opts.start, opts.end,
subject_dn, subject_dn,
extensions);
}
示例11: Key_Constraints
/*
* Sign a PKCS #10 certificate request
*/
X509_Certificate X509_CA::sign_request(const PKCS10_Request& req,
RandomNumberGenerator& rng,
const X509_Time& not_before,
const X509_Time& not_after)
{
Key_Constraints constraints;
if(req.is_CA())
{
constraints = Key_Constraints(KEY_CERT_SIGN | CRL_SIGN);
}
else
{
std::unique_ptr<Public_Key> key(req.subject_public_key());
verify_cert_constraints_valid_for_key_type(*key, req.constraints());
constraints = req.constraints();
}
Extensions extensions = req.extensions();
extensions.replace(
new Cert_Extension::Basic_Constraints(req.is_CA(), req.path_limit()),
true);
if(constraints != NO_CONSTRAINTS)
{
extensions.replace(new Cert_Extension::Key_Usage(constraints), true);
}
extensions.replace(new Cert_Extension::Authority_Key_ID(m_cert.subject_key_id()));
extensions.replace(new Cert_Extension::Subject_Key_ID(req.raw_public_key()));
extensions.replace(
new Cert_Extension::Subject_Alternative_Name(req.subject_alt_name()));
extensions.replace(
new Cert_Extension::Extended_Key_Usage(req.ex_constraints()));
return make_cert(m_signer, rng, m_ca_sig_algo,
req.raw_public_key(),
not_before, not_after,
m_cert.subject_dn(), req.subject_dn(),
extensions);
}
示例12: main
int main()
{
Extensions<int> myExtensions;
for (int i = 0;i < myExtensions.getSize(); i++) {
myExtensions.setValue(i, rand() % 100);
}
cout << "Unsorted: " << endl;
myExtensions.print();
cout << "Sorted: " << endl;
myExtensions.sort();
myExtensions.print();
return 0;
}
示例13: describe
void SkiaBitmapShader::describe(ProgramDescription& description, const Extensions& extensions) {
Texture* texture = mCaches->textureCache.get(mBitmap);
if (!texture) return;
mTexture = texture;
const float width = texture->width;
const float height = texture->height;
description.hasBitmap = true;
// The driver does not support non-power of two mirrored/repeated
// textures, so do it ourselves
if (!extensions.hasNPot() && (!isPowerOfTwo(width) || !isPowerOfTwo(height)) &&
(mTileX != SkShader::kClamp_TileMode || mTileY != SkShader::kClamp_TileMode)) {
description.isBitmapNpot = true;
description.bitmapWrapS = gTileModes[mTileX];
description.bitmapWrapT = gTileModes[mTileY];
mWrapS = GL_CLAMP_TO_EDGE;
mWrapT = GL_CLAMP_TO_EDGE;
} else {
mWrapS = gTileModes[mTileX];
mWrapT = gTileModes[mTileY];
}
}
示例14: Key_Constraints
/*
* Sign a PKCS #10 certificate request
*/
X509_Certificate X509_CA::sign_request(const PKCS10_Request& req,
RandomNumberGenerator& rng,
const X509_Time& not_before,
const X509_Time& not_after)
{
Key_Constraints constraints;
if(req.is_CA())
constraints = Key_Constraints(KEY_CERT_SIGN | CRL_SIGN);
else
{
std::unique_ptr<Public_Key> key(req.subject_public_key());
constraints = find_constraints(*key, req.constraints());
}
Extensions extensions;
extensions.add(
new Cert_Extension::Basic_Constraints(req.is_CA(), req.path_limit()),
true);
extensions.add(new Cert_Extension::Key_Usage(constraints), true);
extensions.add(new Cert_Extension::Authority_Key_ID(cert.subject_key_id()));
extensions.add(new Cert_Extension::Subject_Key_ID(req.raw_public_key()));
extensions.add(
new Cert_Extension::Subject_Alternative_Name(req.subject_alt_name()));
extensions.add(
new Cert_Extension::Extended_Key_Usage(req.ex_constraints()));
return make_cert(signer, rng, ca_sig_algo,
req.raw_public_key(),
not_before, not_after,
cert.subject_dn(), req.subject_dn(),
extensions);
}
示例15: create_cert_req
/*
* Create a PKCS #10 certificate request
*/
PKCS10_Request create_cert_req(const X509_Cert_Options& opts,
const Private_Key& key,
const std::string& hash_fn,
RandomNumberGenerator& rng)
{
AlgorithmIdentifier sig_algo;
X509_DN subject_dn;
AlternativeName subject_alt;
opts.sanity_check();
std::vector<byte> pub_key = X509::BER_encode(key);
std::unique_ptr<PK_Signer> signer(choose_sig_format(key, hash_fn, sig_algo));
load_info(opts, subject_dn, subject_alt);
const size_t PKCS10_VERSION = 0;
Extensions extensions;
extensions.add(
new Cert_Extension::Basic_Constraints(opts.is_CA, opts.path_limit));
extensions.add(
new Cert_Extension::Key_Usage(
opts.is_CA ? Key_Constraints(KEY_CERT_SIGN | CRL_SIGN) :
find_constraints(key, opts.constraints)
)
);
extensions.add(
new Cert_Extension::Extended_Key_Usage(opts.ex_constraints));
extensions.add(
new Cert_Extension::Subject_Alternative_Name(subject_alt));
DER_Encoder tbs_req;
tbs_req.start_cons(SEQUENCE)
.encode(PKCS10_VERSION)
.encode(subject_dn)
.raw_bytes(pub_key)
.start_explicit(0);
if(opts.challenge != "")
{
ASN1_String challenge(opts.challenge, DIRECTORY_STRING);
tbs_req.encode(
Attribute("PKCS9.ChallengePassword",
DER_Encoder().encode(challenge).get_contents_unlocked()
)
);
}
tbs_req.encode(
Attribute("PKCS9.ExtensionRequest",
DER_Encoder()
.start_cons(SEQUENCE)
.encode(extensions)
.end_cons()
.get_contents_unlocked()
)
)
.end_explicit()
.end_cons();
const std::vector<byte> req =
X509_Object::make_signed(signer.get(), rng, sig_algo,
tbs_req.get_contents());
return PKCS10_Request(req);
}