Beispiel #1
0
static int evp_clone(lua_State *L)
{
  EVP_MD_CTX *c = evp_pget(L, 1);
  EVP_MD_CTX *d = evp_pnew(L);
  EVP_MD_CTX_init(d);
  EVP_MD_CTX_copy_ex(d, c);
  return 1;
}
Beispiel #2
0
static int evp_clone(lua_State *L)
{
  HANDLER_EVP *c = evp_pget(L, 1);
  HANDLER_EVP *d = evp_pnew(L);

#if CRYPTO_OPENSSL
  EVP_MD_CTX_init(d);
  EVP_MD_CTX_copy_ex(d, c);
#elif CRYPTO_GCRYPT
  gcry_md_copy(d, *c);
#endif

  return 1;
}
Beispiel #3
0
static int evp_fnew(lua_State *L)
{
  EVP_MD_CTX *c = NULL;
  const char *s = luaL_checkstring(L, 1);
  const EVP_MD *type = EVP_get_digestbyname(s);
  
  if (type == NULL) {
    luaL_argerror(L, 1, "invalid digest type");
    return 0;
  }
  
  c = evp_pnew(L);
  EVP_MD_CTX_init(c);
  EVP_DigestInit_ex(c, type, NULL);
  
  return 1;
}
Beispiel #4
0
static int evp_fnew(lua_State *L)
{
  HANDLER_EVP *c = NULL;
  const char *s = luaL_checkstring(L, 1);
  DIGEST_TYPE type = DIGEST_BY_NAME(s);

  if (IS_DIGEST_INVALID(type)) {
    luaL_argerror(L, 1, "invalid digest type");
    return 0;
  }
  
  c = evp_pnew(L);

#if CRYPTO_OPENSSL
  EVP_MD_CTX_init(c);
  EVP_DigestInit_ex(c, type, NULL); //must return 1 (not checked!)
#elif CRYPTO_GCRYPT
  gcry_md_open(c, type, 0); //returns a gcry_error_t (not checked!)
#endif
  
  return 1;
}