lopy4/components/hash-sigs-master/hss_derive.c
/* This derives the current seed value (actually, we've already computed */
/* it); we just need to copy it to the buffer) */
/* If increment_j is set, it'll then reset the object to the next j value */
/* (which means incrementally computing that path) */
This derives the current seed value (actually, we've already computed
it); we just need to copy it to the buffer)
If increment_j is set, it'll then reset the object to the next j value
(which means incrementally computing that path)
This derives the current seed value ( actually we ' ve already computed it ) ; we just need to copy it to the buffer ) If increment_j is set it ' ll then reset the object to the next j value ( which means incrementally computing that path )
void hss_seed_derive( unsigned char *seed, struct seed_derive *derive,
                      bool increment_j ) {
    memcpy( seed, derive->j_seed[ derive->j_levels - 1], SEED_LEN );
    if (increment_j) {
        int i;
        for (i = derive->j_levels-1;; i--) {
            unsigned index = derive->j_value[i];
            index += 1;
            derive->j_value[i] = index;
            if (0 != (index & SECRET_MAX_MASK)) {
                break;
            }
            if (i == 0) {
               break;
            }
        }
        union hash_context ctx;
        unsigned char buffer[ PRG_MAX_LEN ];
        for (; i < derive->j_levels; i++) {
            set_j_seed( derive, i, &ctx, buffer );
        }
        hss_zeroize( &ctx, sizeof ctx );
        hss_zeroize( buffer, PRG_LEN(SEED_LEN) );
    }
}
void hss_seed_derive ( unsigned char * seed , struct seed_derive * derive , bool increment_j ) { memcpy ( seed , derive -> j_seed [ derive -> j_levels - 1 ] , SEED_LEN ) ; if ( increment_j ) { int i ; for ( i = derive -> j_levels - 1 ; ; i -- ) { unsigned index = derive -> j_value [ i ] ; index += 1 ; derive -> j_value [ i ] = index ; if ( 0 != ( index & SECRET_MAX_MASK ) ) { break ; } if ( i == 0 ) { break ; } } union hash_context ctx ; unsigned char buffer [ PRG_MAX_LEN ] ; for ( ; i < derive -> j_levels ; i ++ ) { set_j_seed ( derive , i , & ctx , buffer ) ; } hss_zeroize ( & ctx , sizeof ctx ) ; hss_zeroize ( buffer , PRG_LEN ( SEED_LEN ) ) ; } }
This derives the current seed value (actually, we've already computed
it); we just need to copy it to the buffer)
If increment_j is set, it'll then reset the object to the next j value
(which means incrementally computing that path)
This derives the current seed value ( actually we ' ve already computed it ) ; we just need to copy it to the buffer ) If increment_j is set it ' ll then reset the object to the next j value ( which means incrementally computing that path )
/* Update the j_values, and figure out which hashes we'll need */ /* to recompute */ /* The increment didn't cause a carry to the next level; */ /* we can stop propogating the increment here (and we */ /* also know this is the top level that we need to */ /* recompute the hashes */ /* This is the top level; stop here */ /* Recompute the hashes that need updating; we need to do it */ /* top-down, as each hash depends on the previous one */