libk  Diff

Differences From Artifact [982620d249]:

To Artifact [91c37b49e7]:


    14     14   
    15     15   	/* error states */
    16     16   	kncond_fail,
    17     17   	kncond_fail_io,
    18     18   	kncond_overflow,
    19     19   	kncond_underflow,
    20     20   	kncond_bad_domain,
           21  +	kncond_bad_base,
           22  + 
    21     23   } kncond;
    22     24   
    23     25   /* this "hard" random number generator
    24     26    * returns a block of random data that
    25     27    * can be used safely in cryptographic
    26     28    * pseudorandom number algorithms such
    27     29    * as e.g. knrands() */
................................................................................
    57     59    * fixed point & floating point numbers
    58     60    * should also be added eventually.
    59     61    * note that these functions use either
    60     62    * two's complement or one's complement
    61     63    * for signed */
    62     64   
    63     65   typedef enum knmode {
    64         -	knmode_saturate = 0x0001, /* 0b001 */
    65         -	knmode_wrap     = 0x0002, /* 0b010 */
    66         -	knmode_fail     = 0x0003, /* 0b011 */
           66  +	/* knmode operations may be or'd with a base;
           67  +	 * base will be inferred by prefix otherwise */
           68  +	knmode_saturate = 0x0001 << 7, /* 0b001 */
           69  +	knmode_wrap     = 0x0002 << 7, /* 0b010 */
           70  +	knmode_fail     = 0x0003 << 7, /* 0b011 */
    67     71   
    68         -	knmode_signed   = 1 << 2, /* 0b100*/
           72  +	knmode_signed   = 1 << 6, /* 0b100*/
    69     73   	knmode_unsigned = 0 /* default */
    70     74   } knmode;
    71     75   
    72         -/* it is legal for src and dest to be the
    73         - * same location in memory. this will not
    74         - * produce incorrect output. although the
    75         - * functions formally take pointers to u8,
    76         - * they are converted  appropriately with
    77         - * regard to sign and size within the fn */
           76  +/* it is legal for  src and dest to be the
           77  + * same location in memory.  this will not
           78  + * produce incorrect output.  although the
           79  + * functions  formally   take  pointers to
           80  + * ubyte, they are converted appropriately
           81  + * with  regard  to sign  and  size within
           82  + * the fn */
    78     83   
    79         -kncond kniadd(knmode, sz, u8* dest, u8* src, u8* delta);
    80         -kncond knisub(knmode, sz, u8* dest, u8* src, u8* delta);
    81         -kncond knimul(knmode, sz, u8* dest, u8* src, u8* delta);
           84  +kncond kniadd(knmode, sz, ubyte* dest, ubyte* src, ubyte* delta);
           85  +kncond knisub(knmode, sz, ubyte* dest, ubyte* src, ubyte* delta);
           86  +kncond knimul(knmode, sz, ubyte* dest, ubyte* src, ubyte* delta);
    82     87   kncond knidiv(knmode, sz,
    83         -	/* output */ u8* ratio, u8* remainder,
    84         -	/*  input */ u8* src, u8* delta);
           88  +	/* output */ ubyte* ratio, ubyte* remainder,
           89  +	/*  input */ ubyte* src, ubyte delta);
    85     90   
    86     91   /* we should probably also offer a bignum
    87     92    * type eventually, tho this will need to
    88     93    * be integrated with kmem for allocation. */
           94  +
           95  +kncond knstr(knmode, sz, char* dest_begin, char* dest_end, ubyte* src);
           96  +kncond knparse(knmode, sz, ubyte* dest, ksraw src);
    89     97   
    90     98   #ifdef __cplusplus
    91     99   	}
    92    100   #endif
    93    101   
    94    102   #endif