本文整理汇总了C++中PUSH_OBJECT函数的典型用法代码示例。如果您正苦于以下问题:C++ PUSH_OBJECT函数的具体用法?C++ PUSH_OBJECT怎么用?C++ PUSH_OBJECT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PUSH_OBJECT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: openssl_xalgor_get
static int openssl_xalgor_get(lua_State* L)
{
int type;
void* val;
ASN1_OBJECT *obj, *dup;
X509_ALGOR* alg = CHECK_OBJECT(1, X509_ALGOR, "openssl.x509_algor");
X509_ALGOR_get0(&obj, &type, &val, alg);
if (obj != NULL)
{
dup = OBJ_dup(obj);
PUSH_OBJECT(dup, "openssl.asn1_object");
}
else
lua_pushnil(L);
if (type == V_ASN1_UNDEF)
lua_pushnil(L);
else
{
ASN1_STRING *s = ASN1_STRING_dup(val);
PUSH_OBJECT(s, "openssl.asn1_string");
}
return 2;
}
示例2: LUA_FUNCTION
static LUA_FUNCTION(openssl_csr_parse)
{
X509_REQ * csr = CHECK_OBJECT(1, X509_REQ, "openssl.x509_req");
X509_NAME * subject = X509_REQ_get_subject_name(csr);
STACK_OF(X509_EXTENSION) *exts = X509_REQ_get_extensions(csr);
lua_newtable(L);
openssl_push_asn1(L, csr->signature, V_ASN1_BIT_STRING);
lua_setfield(L, -2, "signature");
openssl_push_x509_algor(L, csr->sig_alg);
lua_setfield(L, -2, "sig_alg");
lua_newtable(L);
AUXILIAR_SET(L, -1, "version", X509_REQ_get_version(csr), integer);
openssl_push_xname_asobject(L, subject);
lua_setfield(L, -2, "subject");
if (exts)
{
PUSH_OBJECT(exts, "openssl.stack_of_x509_extension");
lua_setfield(L, -2, "extensions");
}
{
X509_REQ_INFO* ri = csr->req_info;
int i, c;
EVP_PKEY *pubkey = X509_REQ_get_pubkey(csr);
lua_newtable(L);
c = X509_REQ_get_attr_count(csr);
if (c > 0)
{
lua_newtable(L);
for (i = 0; i < c ; i++)
{
X509_ATTRIBUTE *attr = X509_REQ_get_attr(csr, i);
attr = X509_ATTRIBUTE_dup(attr);
PUSH_OBJECT(attr, "openssl.x509_attribute");
lua_rawseti(L, -2, i + 1);
}
lua_setfield(L, -2, "attributes");
}
lua_newtable(L);
openssl_push_asn1object(L, ri->pubkey->algor->algorithm);
lua_setfield(L, -2, "algorithm");
AUXILIAR_SETOBJECT(L, pubkey , "openssl.evp_pkey", -1, "pubkey");
lua_setfield(L, -2, "pubkey");
lua_setfield(L, -2, "req_info");
}
return 1;
}
示例3: openssl_eckey_group
static int openssl_eckey_group(lua_State *L)
{
const EC_GROUP* g = openssl_get_ec_group(L, 1, 2, 3);
if (g)
{
const EC_POINT* p = EC_GROUP_get0_generator(g);
p = EC_POINT_dup(p, g);
PUSH_OBJECT(g, "openssl.ec_group");
PUSH_OBJECT(p, "openssl.ec_point");
return 2;
}
return 0;
};
示例4: openssl_ssl_peer
static int openssl_ssl_peer(lua_State*L)
{
SSL* s = CHECK_OBJECT(1, SSL, "openssl.ssl");
X509* x = SSL_get_peer_certificate(s);
STACK_OF(X509) *sk = SSL_get_peer_cert_chain(s);
PUSH_OBJECT(x, "openssl.x509");
if (sk)
{
sk = openssl_sk_x509_dup(sk);
PUSH_OBJECT(sk, "openssl.stack_of_x509");
return 2;
}
return 1;
}
示例5: openssl_ssl_dup
static int openssl_ssl_dup(lua_State*L)
{
SSL* s = CHECK_OBJECT(1, SSL, "openssl.ssl");
SSL* ss = SSL_dup(s);
PUSH_OBJECT(ss, "openssl.ssl");
return 1;
}
示例6: openssl_ssl_session_peer
static int openssl_ssl_session_peer(lua_State*L)
{
SSL_SESSION* session = CHECK_OBJECT(1, SSL_SESSION, "openssl.ssl_session");
X509 *x = SSL_SESSION_get0_peer(session);
PUSH_OBJECT(x, "openssl.x509");
return 1;
}
示例7: openssl_cms_create
static int openssl_cms_create(lua_State*L)
{
CMS_ContentInfo *cms = NULL;
if (lua_gettop(L) == 1)
{
cms = CMS_ContentInfo_new();
}
else
{
BIO* in = load_bio_object(L, 1);
if (lua_isuserdata(L, 2))
{
const EVP_MD* md = get_digest(L, 2);
int flags = luaL_optint(L, 3, 0);
cms = CMS_digest_create(in, md, flags);
}
else
{
int flags = luaL_optint(L, 2, 0);
cms = CMS_data_create(in, flags);
}
}
PUSH_OBJECT(cms, "openssl.cms");
return 1;
}
示例8: openssl_cms_read
static int openssl_cms_read(lua_State *L)
{
BIO* in = load_bio_object(L, 1);
int fmt = luaL_checkoption(L, 2, "auto", format);
CMS_ContentInfo *cms = NULL;
if (fmt == FORMAT_AUTO)
{
fmt = bio_is_der(in) ? FORMAT_DER : FORMAT_PEM;
}
if (fmt == FORMAT_DER)
{
cms = d2i_CMS_bio(in, NULL);
//CMS_ContentInfo *cms = CMS_ContentInfo_new();
//int ret = i2d_CMS_bio(bio, cms);
}else
if (fmt == FORMAT_PEM)
{
cms = PEM_read_bio_CMS(in, NULL, NULL, NULL);
}else
if (fmt == FORMAT_SMIME)
{
BIO *indata = load_bio_object(L, 3);
cms = SMIME_read_CMS(in, &indata);
}
if (cms)
{
PUSH_OBJECT(cms, "openssl.cms");
return 1;
}
return openssl_pushresult(L, 0);
}
示例9: openssl_xattr_dup
static int openssl_xattr_dup(lua_State*L)
{
X509_ATTRIBUTE* attr = CHECK_OBJECT(1, X509_ATTRIBUTE, "openssl.x509_attribute");
X509_ATTRIBUTE* dup = X509_ATTRIBUTE_dup(attr);
PUSH_OBJECT(dup, "openssl.x509_attribute");
return 1;
}
示例10: openssl_xext_dup
static int openssl_xext_dup(lua_State* L)
{
X509_EXTENSION *x = CHECK_OBJECT(1, X509_EXTENSION, "openssl.x509_extension");
X509_EXTENSION *d = X509_EXTENSION_dup(x);
PUSH_OBJECT(d, "openssl.x509_extension");
return 1;
};
示例11: LUA_FUNCTION
static LUA_FUNCTION(openssl_pkcs7_encrypt)
{
PKCS7 * p7 = NULL;
BIO *in = load_bio_object(L, 1);
STACK_OF(X509) *recipcerts = openssl_sk_x509_fromtable(L, 2);
const EVP_CIPHER *cipher = get_cipher(L, 3, "des3");
long flags = luaL_optint(L, 4, 0);
if (cipher == NULL)
{
luaL_error(L, "Failed to get cipher");
}
p7 = PKCS7_encrypt(recipcerts, in, cipher, flags);
BIO_free(in);
sk_X509_pop_free(recipcerts, X509_free);
if (p7 == NULL)
{
lua_pushnil(L);
}
else
{
PUSH_OBJECT(p7, "openssl.pkcs7");
}
return 1;
}
示例12: openssl_ocsp_request_parse
static int openssl_ocsp_request_parse(lua_State*L)
{
OCSP_REQUEST *req = CHECK_OBJECT(1, OCSP_REQUEST, "openssl.ocsp_request");
int utf8 = lua_isnoneornil(L, 2) ? 1 : lua_toboolean(L, 2);
OCSP_REQINFO *inf = req->tbsRequest;
OCSP_SIGNATURE *sig = req->optionalSignature;
BIO* bio = BIO_new(BIO_s_mem());
int i, num;
lua_newtable(L);
AUXILIAR_SET(L, -1, "version", ASN1_INTEGER_get(inf->version), integer);
if (inf->requestorName)
{
opensl_push_general_name(L, inf->requestorName, utf8);
lua_setfield(L, -2, "requestorName");
}
num = sk_OCSP_ONEREQ_num(inf->requestList);
lua_newtable(L);
for (i = 0; i < num; i++)
{
OCSP_ONEREQ *one = sk_OCSP_ONEREQ_value(inf->requestList, i);
OCSP_CERTID *a = one->reqCert;
lua_newtable(L);
{
openssl_push_x509_algor(L, a->hashAlgorithm);
lua_setfield(L, -2, "hashAlgorithm");
PUSH_ASN1_OCTET_STRING(L, a->issuerNameHash);
lua_setfield(L, -2, "issuerNameHash");
PUSH_ASN1_OCTET_STRING(L, a->issuerKeyHash);
lua_setfield(L, -2, "issuerKeyHash");
PUSH_ASN1_INTEGER(L, a->serialNumber);
lua_setfield(L, -2, "serialNumber");
}
lua_rawseti(L, -2, i + 1);
}
lua_setfield(L, -2, "requestList");
if (inf->requestExtensions){
STACK_OF(X509_EXTENSION) *extensions = sk_X509_EXTENSION_dup(inf->requestExtensions);
PUSH_OBJECT(extensions,"openssl.stack_of_x509_extension");
lua_setfield(L,-2, "extensions");
}
if (sig)
{
BIO_reset(bio);
X509_signature_print(bio, sig->signatureAlgorithm, sig->signature);
for (i = 0; i < sk_X509_num(sig->certs); i++)
{
X509_print(bio, sk_X509_value(sig->certs, i));
PEM_write_bio_X509(bio, sk_X509_value(sig->certs, i));
}
}
BIO_free(bio);
return 1;
}
示例13: LUA_FUNCTION
static LUA_FUNCTION(openssl_ts_req_to_verify_ctx)
{
TS_REQ *req = CHECK_OBJECT(1, TS_REQ, "openssl.ts_req");
TS_VERIFY_CTX *ctx = TS_REQ_to_TS_VERIFY_CTX(req, NULL);
PUSH_OBJECT(ctx, "openssl.ts_verify_ctx");
return 1;
}
示例14: openssl_new_xattrs
static int openssl_new_xattrs(lua_State*L)
{
size_t i;
int idx = 1;
STACK_OF(X509_ATTRIBUTE) *attrs = sk_X509_ATTRIBUTE_new_null();
luaL_checktable(L, idx);
for (i = 0; i < lua_rawlen(L, idx); i++)
{
X509_ATTRIBUTE* a = NULL;
const char* eprefix = NULL;
lua_rawgeti(L, idx, i + 1);
if (!lua_istable(L, -1))
{
lua_pushfstring(L, "value at %d is not table", i + 1);
luaL_argerror(L, idx, lua_tostring(L, -1));
}
lua_pushfstring(L, "table %d at argument #%d:", idx, i + 1);
eprefix = lua_tostring(L, -1);
lua_pop(L, 1);
a = openssl_new_xattribute(L, &a, lua_gettop(L), eprefix);
if (a)
{
sk_X509_ATTRIBUTE_push(attrs, a);
}
lua_pop(L, 1);
}
PUSH_OBJECT(attrs, "openssl.stack_of_x509_attribute");
return 1;
}
示例15: LUA_FUNCTION
static LUA_FUNCTION(openssl_evp_digest_init)
{
EVP_MD* md = CHECK_OBJECT(1, EVP_MD, "openssl.evp_digest");
ENGINE* e = lua_gettop(L) > 1 ? CHECK_OBJECT(2, ENGINE, "openssl.engine") : NULL;
EVP_MD_CTX* ctx = EVP_MD_CTX_create();
if (ctx)
{
int ret;
EVP_MD_CTX_init(ctx);
ret = EVP_DigestInit_ex(ctx, md, e);
if (ret == 1)
{
PUSH_OBJECT(ctx, "openssl.evp_digest_ctx");
}
else
{
EVP_MD_CTX_destroy(ctx);
return openssl_pushresult(L, ret);
}
}
else
lua_pushnil(L);
return 1;
}