88064b2011-12-20Henrik Grubbström (Grubba) /* -*- C -*- * * Cmod header-file acting as a template for the hash classes. */
86a7272013-10-05Henrik Grubbström (Grubba) DOCSTART() @class PIKE_NAME *! *! Implementation of the PIKE_NAME hash algorithm.
88064b2011-12-20Henrik Grubbström (Grubba)  *! DOCEND()
86a7272013-10-05Henrik Grubbström (Grubba) PIKECLASS PIKE_NAME
88064b2011-12-20Henrik Grubbström (Grubba) {
86a7272013-10-05Henrik Grubbström (Grubba)  DOCSTART() @decl inherit Hash DOCEND()
895c722014-03-29Henrik Grubbström (Grubba)  INHERIT Nettle_Hash;
86a7272013-10-05Henrik Grubbström (Grubba) 
88064b2011-12-20Henrik Grubbström (Grubba)  INIT {
895c722014-03-29Henrik Grubbström (Grubba)  struct Nettle_Hash_struct *hash; ASSIGN_CURRENT_STORAGE(hash, struct Nettle_Hash_struct, 1, Nettle_Hash_program);
86a7272013-10-05Henrik Grubbström (Grubba)  werror(cmod_STRFY_EVAL(PIKE_NAME) "->INIT\n");
69e2632013-10-20Henrik Grubbström (Grubba)  hash->meta = &cmod_CONCAT_EVAL(nettle_, NETTLE_NAME);
88064b2011-12-20Henrik Grubbström (Grubba)  }
5a1e2e2017-07-19Martin Nilsson #ifdef SPECIAL_PBKDF2 PIKEFUN string pbkdf2(string(8bit) password, string(8bit) salt, int rounds, int bytes) { struct pike_string *dst = begin_shared_string(bytes); NO_WIDE_STRING(password); NO_WIDE_STRING(salt); cmod_CONCAT_EVAL(pbkdf2_hmac_,NETTLE_NAME)(password->len, (const uint8_t *)password->str, rounds, salt->len, (const uint8_t *)salt->str, bytes, (uint8_t *)dst->str); push_string(end_shared_string(dst)); } #endif
86a7272013-10-05Henrik Grubbström (Grubba)  DOCSTART() @class State *! *! State for PIKE_NAME hashing. *! DOCEND() PIKECLASS State program_flags PROGRAM_NEEDS_PARENT|PROGRAM_USES_PARENT; {
4561b62013-10-05Henrik Grubbström (Grubba)  DOCSTART() @decl inherit Hash::State DOCEND()
86a7272013-10-05Henrik Grubbström (Grubba)  EXTRA {
0bb0ef2013-10-19Henrik Grubbström (Grubba)  /* Perform an inherit of the Hash.State class that our parent * contains via its inherit of Hash.
86a7272013-10-05Henrik Grubbström (Grubba)  */
b715e52017-07-31Martin Nilsson  inherit_internal_class(MK_STRING("State"));
86a7272013-10-05Henrik Grubbström (Grubba)  }
88064b2011-12-20Henrik Grubbström (Grubba)  CVAR struct cmod_CONCAT_EVAL(NETTLE_NAME, _ctx) NETTLE_NAME; INIT {
895c722014-03-29Henrik Grubbström (Grubba)  struct Nettle_Hash_State_struct *instance; ASSIGN_CURRENT_STORAGE(instance, struct Nettle_Hash_State_struct, 1, Nettle_Hash_State_program);
88064b2011-12-20Henrik Grubbström (Grubba) 
69e2632013-10-20Henrik Grubbström (Grubba)  werror(cmod_STRFY_EVAL(PIKE_NAME) ".State->INIT\n");
88064b2011-12-20Henrik Grubbström (Grubba)  cmod_CONCAT_EVAL(NETTLE_NAME, _init)(&THIS->NETTLE_NAME); instance->ctx = &THIS->NETTLE_NAME; }
86a7272013-10-05Henrik Grubbström (Grubba)  } DOCSTART() @endclass State DOCEND()
88064b2011-12-20Henrik Grubbström (Grubba) }
86a7272013-10-05Henrik Grubbström (Grubba) DOCSTART() @endclass PIKE_NAME
88064b2011-12-20Henrik Grubbström (Grubba) DOCEND()
86a7272013-10-05Henrik Grubbström (Grubba)