lopy4/components/hash-sigs-master/hss_derive.c
/* This sets the internal 'j' value for seed derivation object */
/* This computes the entire path to the 'j' value.  Because this is used */
/* immediately after resetting the q value, we don't try to reuse the */
/* previous hashes (as there won't be anything there we could reuse) */
/* Note that we don't try to take advantage of any preexisting hashes */
/* in the j_seed array; we don't bother because this function is typically */
/* used only immediately after a set_q call, and so there aren't any */
/* hashes we could take advantage of */
This sets the internal 'j' value for seed derivation object
This computes the entire path to the 'j' value.
This sets the internal ' j ' value for seed derivation object This computes the entire path to the ' j ' value .
void hss_seed_derive_set_j( struct seed_derive *derive, unsigned j ) {
    int i;
    unsigned j_levels = derive->j_levels;
    unsigned shift = SECRET_MAX * j_levels;
    unsigned j_mask = derive->j_mask;
    j &= j_mask-1; 
    j |= j_mask;  
    union hash_context ctx;
    unsigned char buffer[ PRG_MAX_LEN ];
    for (i = 0; i<j_levels; i++ ) {
        shift -= SECRET_MAX;
        derive->j_value[i] = (j >> shift);
        set_j_seed( derive, i, &ctx, buffer );
    }
    hss_zeroize( &ctx, sizeof ctx );
    hss_zeroize( buffer, PRG_LEN(SEED_LEN) );
}
void hss_seed_derive_set_j ( struct seed_derive * derive , unsigned j ) { int i ; unsigned j_levels = derive -> j_levels ; unsigned shift = SECRET_MAX * j_levels ; unsigned j_mask = derive -> j_mask ; j &= j_mask - 1 ; j |= j_mask ; union hash_context ctx ; unsigned char buffer [ PRG_MAX_LEN ] ; for ( i = 0 ; i < j_levels ; i ++ ) { shift -= SECRET_MAX ; derive -> j_value [ i ] = ( j >> shift ) ; set_j_seed ( derive , i , & ctx , buffer ) ; } hss_zeroize ( & ctx , sizeof ctx ) ; hss_zeroize ( buffer , PRG_LEN ( SEED_LEN ) ) ; }
This sets the internal 'j' value for seed derivation object
This computes the entire path to the 'j' value.
This sets the internal ' j ' value for seed derivation object This computes the entire path to the ' j ' value .
/* Set the high-order bit; clear any bits above that */ /* This ensures that when we do the hashes, that the */ /* prefix for the hashes at two different levels of the */ /* tree are distinct */