pike.git
/
src
/
post_modules
/
Nettle
/
hash.H
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/post_modules/Nettle/hash.H:19:
struct Nettle_Hash_struct *hash; ASSIGN_CURRENT_STORAGE(hash, struct Nettle_Hash_struct, 1, Nettle_Hash_program); werror(cmod_STRFY_EVAL(PIKE_NAME) "->INIT\n"); hash->meta = &cmod_CONCAT_EVAL(nettle_, NETTLE_NAME); } #ifdef SPECIAL_PBKDF2
-
PIKEFUN string pbkdf2(string(8bit) password, string(8bit) salt,
+
PIKEFUN string
(8bit)
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 #ifdef HAVE_NETTLE_HMAC_H
-
+
DOCSTART() @module HMAC
+
*!
+
*! Accellerated implementation of HMAC (Hashing for Message Authenticity
+
*! Control) with the PIKE_NAME hash algorithm.
+
*!
+
*! @seealso
+
*! @[Crypto.HMAC]
+
DOCEND()
PIKECLASS _HMAC flags ID_PROTECTED; { EXTRA { lexical_inherit(1, MK_STRING("_HMAC"), 0, REPORT_ERROR); }
-
+
DOCSTART() @class PIKE_NAME
+
*! The HMAC hash state.
+
DOCEND()
PIKECLASS State { CVAR struct HMAC_CTX(struct cmod_CONCAT_EVAL(NETTLE_NAME, _ctx)) ctx; CVAR const struct nettle_hash *meta; static int cmod_CONCAT_EVAL(f_Hash__HMAC_, NETTLE_NAME, _create_fun_num) = -1; EXTRA { int hmac_create_fun_num = -1; lexical_inherit(1, MK_STRING("State"), 0, REPORT_ERROR); hmac_create_fun_num = FIND_LFUN(Pike_compiler->new_program->inherits[1].prog, LFUN_CREATE); if (hmac_create_fun_num >= 0) { cmod_CONCAT_EVAL(f_Hash__HMAC_, NETTLE_NAME, _create_fun_num) = really_low_reference_inherited_identifier(NULL, 1, hmac_create_fun_num); } }
-
+
DOCSTART() @decl void create(string(8bit) passwd, void|int b)
+
*! @param passwd
+
*! The secret password (K).
+
*!
+
*! @param b
+
*! Block size. Must @expr{0@} (zero) or equal to the @[block_size()].
+
DOCEND()
PIKEFUN void create(string(8bit) passwd, void|int b) { const struct nettle_hash *meta = THIS->meta = ((struct Nettle_Hash_struct *)parent_storage(2, Nettle_Hash_program))->meta; NO_WIDE_STRING(passwd); HMAC_SET_KEY(&THIS->ctx, meta, passwd->len, (const uint8_t *)passwd->str); if (cmod_CONCAT_EVAL(f_Hash__HMAC_, NETTLE_NAME, _create_fun_num) != -1) { /* Pass along the password to the inherited pike-level code. */ apply_current(cmod_CONCAT_EVAL(f_Hash__HMAC_, NETTLE_NAME, _create_fun_num), args); }
pike.git/src/post_modules/Nettle/hash.H:147:
find_external_context(&loc, 2); id = find_identifier("pkcs_digest", loc.o->prog); if( id<0 ) Pike_error("Could not find pkcs_digest.\n"); apply_low(loc.o, id + loc.inherit->identifier_level, 1); } else Pike_error("Apply on parent of destructed object.\n"); } }
+
DOCSTART() @endclass PIKE_NAME
+
DOCEND()
} #endif
-
+
DOCSTART() @endmodule HMAC
+
DOCEND()
DOCSTART() @class State *! *! State for PIKE_NAME hashing. *! DOCEND() PIKECLASS State program_flags PROGRAM_NEEDS_PARENT|PROGRAM_USES_PARENT; { DOCSTART() @decl inherit Hash::State