Exemplo n.º 1
0
maybe_vstma_unique_ptr<To> createInstance_impl(Factory *factory, Steinberg::FUID class_id, Steinberg::FIDString iid)
{
    assert(factory);
	To *obtained = nullptr;

	Steinberg::tresult const res = factory->createInstance(class_id, iid, (void **)&obtained);
	if(res == Steinberg::kResultTrue && obtained) {
        return { to_unique(obtained) };
	} else {
        return { res };
	}
}
Exemplo n.º 2
0
maybe_vstma_unique_ptr<To> queryInterface_impl(T *p, Steinberg::FIDString iid)
{
    assert(p);

	To *obtained = nullptr;
	Steinberg::tresult const res = p->queryInterface(iid, (void **)&obtained);
	if(res == Steinberg::kResultTrue && obtained) {
        return { to_unique(obtained) };
	} else {
		if(res != Steinberg::kResultTrue) {
            return { res };
		} else {
            return { Steinberg::kNoInterface };
		}
	}
}
Exemplo n.º 3
0
std::string
hash(const std::uint8_t *begin, const std::uint8_t *end)
{
  SECOidTag hashOIDTag = SEC_OID_SHA256;
  std::array<std::uint8_t, 64> digest;
  unsigned int len;
  
  HASH_HashType hashType = HASH_GetHashTypeByOidTag(hashOIDTag);
  
  auto ctx = to_unique(HASH_Create(hashType));
  HASH_Begin(ctx.get());
  HASH_Update(ctx.get(),
    reinterpret_cast<const unsigned char *>(begin), end - begin);
  HASH_End(ctx.get(),
    reinterpret_cast<unsigned char *>(digest.data()), &len, digest.size());
  
  return std::string(reinterpret_cast<const char *>(digest.data()), len);
}
Exemplo n.º 4
0
std::string
certPubKeyHash(CERTCertificate* cert)
{
  auto pubKey = to_unique(CERT_ExtractPublicKey(cert));
  return pubKeyHash(pubKey.get());
}
Exemplo n.º 5
0
std::string
pubKeyHash(SECKEYPublicKey* key)
{
  auto derPubKey = to_unique(SECKEY_EncodeDERSubjectPublicKeyInfo(key));
  return hash(derPubKey->data, derPubKey->data + derPubKey->len);
}