pike.git
/
src
/
post_modules
/
Nettle
/
nettle.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/post_modules/Nettle/nettle.cmod:203:
/*! @decl int(0..) needed_sources() *! The number of sources that must reach the threshold before a *! slow reseed will happen. */ PIKEFUN int(0..) needed_sources() optflags OPT_EXTERNAL_DEPEND; { RETURN yarrow256_needed_sources(&THIS->ctx); }
-
/*! @decl string(0..255) random_string(int length)
+
/*! @decl string(0..255) random_string(int
(0..)
length)
*! Returns a pseudo-random string of the requested @[length]. */
-
PIKEFUN string(0..255) random_string(int length)
+
PIKEFUN string(0..255) random_string(int
(0..)
length)
optflags OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT; { struct pike_string *rnd; if(length < 0) Pike_error("Invalid length, must be positive.\n"); if( !yarrow256_is_seeded(&THIS->ctx) ) Pike_error("Random generator not seeded.\n"); rnd = begin_shared_string(length); yarrow256_random(&THIS->ctx, length, (uint8_t *)rnd->str); RETURN end_shared_string(rnd);
pike.git/src/post_modules/Nettle/nettle.cmod:322:
INCREMENT(16, THIS->ctr); } /*! @decl string(8bit) random_string(int(0..) len) *! *! Generates @[len] amount of pseudo random data. In contrast with *! the Fortuna PseudoRandomData function, which only allows 2^20 *! bytes of random data per call, the necessary rekey operations *! are here performed internally, so no such restrictions apply. */
-
PIKEFUN string(8bit) random_string(int len)
+
PIKEFUN string(8bit) random_string(int
(0..)
len)
{ int stored = 0; struct pike_string *s; uint8_t *str; if(len<0) Pike_error("Length has to be positive.\n"); s = begin_shared_string(len); str = (uint8_t *)s->str;
pike.git/src/post_modules/Nettle/nettle.cmod:487:
flags ID_PROTECTED; { Pike_error("Requires reseed.\n"); } /*! @decl string(8bit) random_string(int(0..) len) *! *! Generates @[len] amount of pseudo random data. Does not allow *! for additional input data in the call. */
-
PIKEFUN string(8bit) random_string(int len)
+
PIKEFUN string(8bit) random_string(int
(0..)
len)
{ int stored = 0; struct pike_string *s; uint8_t *str; if(len<0) Pike_error("Length has to be positive.\n"); if(THIS->reseed_counter>THIS->reseed_interval) apply_current(f_Nettle_AES128_CTR_DRBG_entropy_underflow_fun_num, 0); s = begin_shared_string(len);
pike.git/src/post_modules/Nettle/nettle.cmod:563:
*! RSAES-PKCS1-V1_5-ENCODE(message) in PKCS#1 v2.2, but without the *! null byte prefix. The padding method used on the original message *! must be provided in the @[type] parameter. All content dependent *! processing is done in constant time for the same padding type and *! @[data] length. *! *! @returns *! Returns the position in the string where the first non-padding *! character is, or 0. */
-
PIKEFUN int(0..) rsa_unpad(string(0..255) data, int type)
+
PIKEFUN int(0..) rsa_unpad(string(0..255) data, int
(1..2)
type)
{ int i, pad=0, nonpad=0, pos=0; unsigned char *str; NO_WIDE_STRING(data); /* Indata is smaller than minimum size, so we can exit immediately without timing issue. 1 type + 8 padding + 1 delimiter + 1 value = 11 bytes. */ if(data->len < 11 ) RETURN 0;
pike.git/src/post_modules/Nettle/nettle.cmod:736:
*! Implements the Castagnoli CRC, CRC32C. Hardware optimized on Intel *! CPUs with SSE 4.2. *! *! @param seed *! Can be fed with the result of the previous invocation to chain on new data. *! Defaults to zero on virgin runs. */ PIKEFUN int(0..) crc32c(string(8bit) data, void|int(0..) seed) { unsigned int h = 0;
-
if(seed)
{
-
if (TYPEOF(*seed) != PIKE_T_INT)
-
Pike_error("Bad argument type.\n");
+
if(seed)
h = seed->u.integer;
-
}
+
#ifdef HAVE_CRC32_INTRINSICS if(supports_sse42) { push_int64(intel_crc32c((const unsigned int *)data->str, data->len, h)); } else #endif /* HAVE_CRC32_INTRISINCS */ { unsigned int i=0, len = data->len; for(h = ~h; i<len; i++)