aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatarLibravatar William Ahern <william@25thandclement.com> 2016-11-23 17:06:43 -0800
committerLibravatarLibravatar William Ahern <william@25thandclement.com> 2016-11-23 17:06:43 -0800
commit612c4ca3033268d70e6aee16d72e721e91f7e87a (patch)
tree1ef301fd4e0611c208197d47bea97dc1ddf240f5 /src
parentf25f81ecda73b894066063050e1f706f3382c4cc (diff)
parentcb727f97f2e00512c70631210de2d8b951e81587 (diff)
downloadluaossl-612c4ca3033268d70e6aee16d72e721e91f7e87a.tar.gz
luaossl-612c4ca3033268d70e6aee16d72e721e91f7e87a.tar.bz2
luaossl-612c4ca3033268d70e6aee16d72e721e91f7e87a.zip
Merge branch 'master' into 63-evp_pkey_get_default_digest_nid-getPublicKeyDigest
Diffstat (limited to 'src')
-rw-r--r--src/openssl.c153
1 files changed, 39 insertions, 114 deletions
diff --git a/src/openssl.c b/src/openssl.c
index b14090e..e5b55ca 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -201,14 +201,6 @@
#define HAVE_EVP_PKEY_ID OPENSSL_PREREQ(1,1,0)
#endif
-#ifndef HAVE_GENERAL_NAME_GET0_VALUE
-#define HAVE_GENERAL_NAME_GET0_VALUE OPENSSL_PREREQ(1,1,0)
-#endif
-
-#ifndef HAVE_GENERAL_NAME_SET0_VALUE
-#define HAVE_GENERAL_NAME_SET0_VALUE OPENSSL_PREREQ(1,1,0)
-#endif
-
#ifndef HAVE_HMAC_CTX_FREE
#define HAVE_HMAC_CTX_FREE OPENSSL_PREREQ(1,1,0)
#endif
@@ -830,8 +822,9 @@ NOTUSED static auxtype_t auxL_getref(lua_State *L, auxref_t ref) {
static int auxL_testoption(lua_State *L, int index, const char *def, const char *const *optlist, _Bool nocase) {
const char *optname = (def)? luaL_optstring(L, index, def) : luaL_checkstring(L, index);
int (*optcmp)() = (nocase)? &strcasecmp : &strcmp;
+ int i;
- for (int i = 0; optlist[i]; i++) {
+ for (i = 0; optlist[i]; i++) {
if (0 == optcmp(optlist[i], optname))
return i;
}
@@ -987,9 +980,11 @@ static inline size_t auxL_liblen(const auxL_Reg *l) {
static void auxL_setfuncs(lua_State *L, const auxL_Reg *l, int nups) {
for (; l->name; l++) {
+ int i;
+
/* copy shared upvalues */
luaL_checkstack(L, nups, "too many upvalues");
- for (int i = 0; i < nups; i++)
+ for (i = 0; i < nups; i++)
lua_pushvalue(L, -nups);
/* nil-fill local upvalues */
@@ -1450,68 +1445,6 @@ static void *compat_EVP_PKEY_get0(EVP_PKEY *key) {
} /* compat_EVP_PKEY_get0() */
#endif
-#if !HAVE_GENERAL_NAME_GET0_VALUE
-#define GENERAL_NAME_get0_value(...) \
- compat_GENERAL_NAME_get0_value(__VA_ARGS__)
-
-static void *GENERAL_NAME_get0_value(GENERAL_NAME *name, int *type) {
- if (type)
- *type = name->type;
- switch (name->type) {
- case GEN_X400:
- case GEN_EDIPARTY:
- return name->d.other;
- case GEN_OTHERNAME:
- return name->d.otherName;
- case GEN_EMAIL:
- case GEN_DNS:
- case GEN_URI:
- return name->d.ia5;
- case GEN_DIRNAME:
- return name->d.dirn;
- case GEN_IPADD:
- return name->d.ip;
- case GEN_RID:
- return name->d.rid;
- default:
- return NULL;
- }
-} /* compat_GENERAL_NAME_get0_value() */
-#endif
-
-#if !HAVE_GENERAL_NAME_SET0_VALUE
-#define GENERAL_NAME_set0_value(...) \
- compat_GENERAL_NAME_set0_value(__VA_ARGS__)
-
-static void GENERAL_NAME_set0_value(GENERAL_NAME *name, int type, void *value) {
- switch ((name->type = type)) {
- case GEN_X400:
- case GEN_EDIPARTY:
- name->d.other = value;
- break;
- case GEN_OTHERNAME:
- name->d.otherName = value;
- break;
- case GEN_EMAIL:
- case GEN_DNS:
- case GEN_URI:
- name->d.ia5 = value;
- break;
- case GEN_DIRNAME:
- name->d.dirn = value;
- break;
- case GEN_IPADD:
- name->d.ip = value;
- break;
- case GEN_RID:
- name->d.rid = value;
- break;
- default:
- break;
- }
-} /* compat_GENERAL_NAME_set0_value() */
-#endif
-
#if !HAVE_HMAC_CTX_FREE
#define HMAC_CTX_free(ctx) compat_HMAC_CTX_free((ctx))
@@ -2568,7 +2501,7 @@ static BN_CTX *getctx(lua_State *L) {
} /* getctx() */
-static int bn_tobin(lua_State *L) {
+static int bn_toBinary(lua_State *L) {
BIGNUM *bn = checksimple(L, 1, BIGNUM_CLASS);
size_t len;
void *dst;
@@ -2579,7 +2512,7 @@ static int bn_tobin(lua_State *L) {
lua_pushlstring(L, dst, len);
return 1;
-} /* bn_tobin() */
+} /* bn_toBinary() */
static int bn__add(lua_State *L) {
@@ -2810,7 +2743,7 @@ static int bn_isPrime(lua_State *L) {
static BIO *getbio(lua_State *);
-static int bn_todec(lua_State *L) {
+static int bn_toDecimal(lua_State *L) {
BIGNUM *bn = checksimple(L, 1, BIGNUM_CLASS);
char *txt = NULL;
BIO *bio;
@@ -2835,11 +2768,11 @@ static int bn_todec(lua_State *L) {
sslerr:
OPENSSL_free(txt);
- return auxL_error(L, auxL_EOPENSSL, "bignum:todec");
-} /* bn_todec() */
+ return auxL_error(L, auxL_EOPENSSL, "bignum:toDecimal");
+} /* bn_toDecimal() */
-static int bn_tohex(lua_State *L) {
+static int bn_toHex(lua_State *L) {
BIGNUM *bn = checksimple(L, 1, BIGNUM_CLASS);
char *txt = NULL;
BIO *bio;
@@ -2864,27 +2797,31 @@ static int bn_tohex(lua_State *L) {
sslerr:
OPENSSL_free(txt);
- return auxL_error(L, auxL_EOPENSSL, "bignum:tohex");
-} /* bn_tohex() */
+ return auxL_error(L, auxL_EOPENSSL, "bignum:toHex");
+} /* bn_toHex() */
static const auxL_Reg bn_methods[] = {
- { "add", &bn__add },
- { "sub", &bn__sub },
- { "mul", &bn__mul },
- { "sqr", &bn_sqr },
- { "idiv", &bn__idiv },
- { "mod", &bn__mod },
- { "nnmod", &bn_nnmod },
- { "exp", &bn__pow },
- { "gcd", &bn_gcd },
- { "lshift", &bn__shl },
- { "rshift", &bn__shr },
- { "isPrime", &bn_isPrime },
- { "tobin", &bn_tobin },
- { "todec", &bn_todec },
- { "tohex", &bn_tohex },
- { NULL, NULL },
+ { "add", &bn__add },
+ { "sub", &bn__sub },
+ { "mul", &bn__mul },
+ { "sqr", &bn_sqr },
+ { "idiv", &bn__idiv },
+ { "mod", &bn__mod },
+ { "nnmod", &bn_nnmod },
+ { "exp", &bn__pow },
+ { "gcd", &bn_gcd },
+ { "lshift", &bn__shl },
+ { "rshift", &bn__shr },
+ { "isPrime", &bn_isPrime },
+ { "toBinary", &bn_toBinary },
+ { "toDecimal", &bn_toDecimal },
+ { "toHex", &bn_toHex },
+ /* deprecated */
+ { "tobin", &bn_toBinary },
+ { "todec", &bn_toDecimal },
+ { "tohex", &bn_toHex },
+ { NULL, NULL },
};
static const auxL_Reg bn_metatable[] = {
@@ -2902,7 +2839,7 @@ static const auxL_Reg bn_metatable[] = {
{ "__lt", &bn__lt },
{ "__le", &bn__le },
{ "__gc", &bn__gc },
- { "__tostring", &bn_todec },
+ { "__tostring", &bn_toDecimal },
{ NULL, NULL },
};
@@ -3871,13 +3808,15 @@ static int pk_getParameters(lua_State *L) {
return luaL_error(L, "%d: unsupported EVP_PKEY base type", base_type);
if (lua_isnoneornil(L, 2)) {
+ const char *const *optname;
+
/*
* Use special "{" parameter to tell loop to push table.
* Subsequent parameters will be assigned as fields.
*/
lua_pushstring(L, "{");
luaL_checkstack(L, nopts, "too many arguments");
- for (const char *const *optname = optlist; *optname; optname++) {
+ for (optname = optlist; *optname; optname++) {
lua_pushstring(L, *optname);
}
}
@@ -4057,11 +3996,12 @@ static const auxL_Reg pk_globals[] = {
};
static void pk_luainit(lua_State *L, _Bool reset) {
+ char **k;
if (!auxL_newmetatable(L, PKEY_CLASS, reset))
return;
auxL_setfuncs(L, pk_metatable, 0);
auxL_newlib(L, pk_methods, 0);
- for (char **k = (char *[]){ "__index", "__newindex", 0 }; *k; k++) {
+ for (k = (char *[]){ "__index", "__newindex", 0 }; *k; k++) {
lua_getfield(L, -2, *k); /* closure */
lua_pushvalue(L, -2); /* method table */
lua_setupvalue(L, -2, 1);
@@ -4110,21 +4050,6 @@ static EC_GROUP *ecg_dup_nil(lua_State *L, const EC_GROUP *src) {
return (src)? ecg_dup(L, src) : (lua_pushnil(L), (EC_GROUP *)0);
} /* ecg_dup_nil() */
-static EC_GROUP *ecg_new_by_nid(int nid) {
- EC_GROUP *group;
-
- if (!(group = EC_GROUP_new_by_curve_name(nid)))
- return NULL;
-
- /* flag as named for benefit of __tostring */
- EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE);
-
- /* compressed points may be patented */
- EC_GROUP_set_point_conversion_form(group, POINT_CONVERSION_UNCOMPRESSED);
-
- return group;
-} /* ecg_new_by_nid() */
-
static EC_GROUP *ecg_push_by_nid(lua_State *L, int nid) {
EC_GROUP **group = prepsimple(L, EC_GROUP_CLASS);