void crypto777_user(struct crypto777_user *user,uint64_t nxt64bits,int32_t numchallenges,uint32_t range)
{
    SaM_Initialize(&user->XORpad);
    user->nxt64bits = nxt64bits;
    memset(&user->shared_SaM,0,sizeof(user->shared_SaM));
    //if ( (user->numchallenges= numchallenges) != 0 )
    //    user->challenges = realloc(user->challenges,numchallenges * sizeof(*user->challenges));
    //user->range = range;
}
Exemple #2
0
void crypto777_encrypt(HUFF *dest,HUFF *src,int32_t len,struct crypto777_user *sender,uint32_t timestamp)
{
    bits256 hash; bits384 xorpad; int32_t i; uint64_t *ptr = (uint64_t *)src->buf;
    hseek(dest,len << 3,SEEK_SET), hrewind(dest), hseek(src,len << 3,SEEK_SET), hrewind(src);
    calc_sha256cat(hash.bytes,(uint8_t *)&sender->nxt64bits,sizeof(sender->nxt64bits),(uint8_t *)&timestamp,sizeof(timestamp));
    SaM_Initialize(&sender->XORpad);
    SaM_Absorb(&sender->XORpad,hash.bytes,sizeof(hash.bytes),sender->shared_SaM.bytes,sizeof(sender->shared_SaM));
    while ( len >= sizeof(xorpad) )
    {
        SaM_emit(&sender->XORpad);
        for (i=0; i<6; i++)
            xorpad.ulongs[i] = (sender->XORpad.bits.ulongs[i] ^ ptr[i]);//, printf("%llx ",(long long)xorpad.ulongs[i]);
        ptr += 6;
        hmemcpy(0,xorpad.bytes,dest,sizeof(xorpad)), len -= sizeof(xorpad);
    }
    if ( len > 0 )
    {
        SaM_emit(&sender->XORpad);
        for (i=0; i<len; i++)
            xorpad.bytes[i] = (sender->XORpad.bits.bytes[i] ^ ((uint8_t *)ptr)[i]);//, printf("%2x ",xorpad.bytes[i]);
        hmemcpy(0,xorpad.bytes,dest,len), len -= sizeof(xorpad);
    }
    //printf(" dest %llu\n",(long long)sender->nxt64bits);
}