Ejemplo n.º 1
0
static int set_curve(lua_State *L)
{
  long ret;
  SSL_CTX *ctx = lsec_checkcontext(L, 1);
  const char *str = luaL_checkstring(L, 2);
  EC_KEY *key = find_ec_key(str);

  if (!key) {
    lua_pushboolean(L, 0);
    lua_pushfstring(L, "elliptic curve %s not supported", str);
    return 2;
  }

  ret = SSL_CTX_set_tmp_ecdh(ctx, key);
  /* SSL_CTX_set_tmp_ecdh takes its own reference */
  EC_KEY_free(key);

  if (!ret) {
    lua_pushboolean(L, 0);
    lua_pushfstring(L, "error setting elliptic curve (%s)",
      ERR_reason_error_string(ERR_get_error()));
    return 2;
  }
  lua_pushboolean(L, 1);
  return 1;
}
Ejemplo n.º 2
0
static int set_curve(lua_State *L)
{
  SSL_CTX *ctx = lsec_checkcontext(L, 1);
  const char *str = luaL_checkstring(L, 2);
  EC_KEY *key = find_ec_key(str);
  if (!key) {
    lua_pushboolean(L, 0);
    lua_pushstring(L, "elliptic curve not supported");
    return 2;
  }
  if (!SSL_CTX_set_tmp_ecdh(ctx, key)) {
    lua_pushboolean(L, 0);
    lua_pushstring(L, "error setting elliptic curve");
    return 2;
  }
  lua_pushboolean(L, 1);
  return 1;
}