lopy4/components/hash-sigs-master/hss_param.c
/*
 * Convert a parameter set into the compressed version we use within a private
 * key.  This is the private key that'll end up being updated constantly, and
 * so we try to make it as small as possible
 */
Convert a parameter set into the compressed version we use within a private
key.  This is the private key that'll end up being updated constantly, and
so we try to make it as small as possible
Convert a parameter set into the compressed version we use within a private key . This is the private key that ' ll end up being updated constantly and so we try to make it as small as possible
bool hss_compress_param_set( unsigned char *compressed,
                   int levels, 
                   const param_set_t *lm_type,
                   const param_set_t *lm_ots_type,
                   size_t len_compressed ) {
    int i;
    for (i=0; i<levels; i++) {
        if (len_compressed == 0) return false;
        param_set_t a = *lm_type++;
        param_set_t b = *lm_ots_type++;
        if (a > 0x0e || b > 0x0e) return false;
        switch (a) {
        case LMS_SHA256_N32_H5: case LMS_SHA256_N32_H10:
        case LMS_SHA256_N32_H15: case LMS_SHA256_N32_H20:
        case LMS_SHA256_N32_H25:
            break;
        default:
            return false;
        }
        switch (b) {
        case LMOTS_SHA256_N32_W1: case LMOTS_SHA256_N32_W2:
        case LMOTS_SHA256_N32_W4: case LMOTS_SHA256_N32_W8:
            break;
        default:
            return false;
        }
        *compressed++ = (a<<4) + b;
        len_compressed--;
    }
    while (len_compressed) {
        *compressed++ = PARM_SET_END;
        len_compressed--;
    }
    return true;
}
bool hss_compress_param_set ( unsigned char * compressed , int levels , const param_set_t * lm_type , const param_set_t * lm_ots_type , size_t len_compressed ) { int i ; for ( i = 0 ; i < levels ; i ++ ) { if ( len_compressed == 0 ) return false ; param_set_t a = * lm_type ++ ; param_set_t b = * lm_ots_type ++ ; if ( a > 0x0e || b > 0x0e ) return false ; switch ( a ) { case LMS_SHA256_N32_H5 : case LMS_SHA256_N32_H10 : case LMS_SHA256_N32_H15 : case LMS_SHA256_N32_H20 : case LMS_SHA256_N32_H25 : break ; default : return false ; } switch ( b ) { case LMOTS_SHA256_N32_W1 : case LMOTS_SHA256_N32_W2 : case LMOTS_SHA256_N32_W4 : case LMOTS_SHA256_N32_W8 : break ; default : return false ; } * compressed ++ = ( a << 4 ) + b ; len_compressed -- ; } while ( len_compressed ) { * compressed ++ = PARM_SET_END ; len_compressed -- ; } return true ; }
Convert a parameter set into the compressed version we use within a private
 key.
Convert a parameter set into the compressed version we use within a private key .
/* All the parameter sets we support are small */ /* Review this format if we need to support larger ones */ /* Make sure the parm sets are supported */