MeteO
October 11th, 2001, 19:40
/**************************************************************************
*
* This code is only for demo and educational use!
*
* The HASP(R)codegenerator and its documentation are copyrighted by //UCL.
* All rights reserved.
*
* This is *complete* HASP seed code generator for NetHASP(TM), MacHASP(TM),
* DataHASP(TM), TimeHASP(TM), SerialHASP(TM), HASP36(TM), MemoHASP36(TM),
* NetHASP36(TM), OpenHASP(TM), HASPCard(TM) of Aladdin Knowledge Systems Ltd.
*
* (c)1998 by MeteO, Fixit
* e-mail us: meteo@null.net
* admin@fixit.spb.ru
*************************************************************************/
#include <stdio.h>
long pwd;
char al_buf[8];
static unsigned char ch[10];
unsigned int tab[64];
unsigned int seed,j,k;
HASP_rows[8][8]={
{0,0,0,0,0,0,0,0},
{0,1,0,1,0,1,0,1},
{1,0,1,0,1,0,1,0},
{0,0,1,1,0,0,1,1},
{1,1,0,0,1,1,0,0},
{0,0,0,0,1,1,1,1},
{1,1,1,1,0,0,0,0},
{1,1,1,1,1,1,1,1}
};
/***************************************
The table is represented as triads
***************************************/
void xor_pwd(void)
{
int i;
pwd^=0x09071966; /* Guess, whose birthday..

*/
for(i=0;i<8;i++)
{
al_buf[I]= pwd & 7;
pwd = pwd >> 3;
}
};
/***************************************
Main function (HASP_seed)
Original code by bajunny
****************************************/
void emulate_func2( unsigned short seed)
{
int i, j;
for(i=0;i<8;i++)
{
ch[I] = 0;
for(j=0;j<8;j++)
{
seed *= 0x1989;
seed += 5;
ch[I] |= (tab[(seed>>9)&0x3f]) << (7-j);
}
}
}
void main(void)
{
int i;
printf("\nInput 1st HASP password:"

;
scanf("%4X",(int*) &j);
printf("Input 2nd HASP password:"

;
scanf("%4X",(int*) &k);
pwd=(long) k*0x10000+j;
printf("\nInput HASP seedcode:"

;
scanf("%x", (int*) &seed);
xor_pwd();
/************************************
Compute universal secret table
*************************************/
for(i=0;i<8;i++){
for(j=0;j<8;j++){tab[i+j*8]=HASP_rows[al_buf[I]][j];}
}
for(i=0;i<8;i++){
for(j=0;j<8;j++){printf("%1.1d",tab[i*8+j]);}
printf("\n"

;
}
emulate_func2(seed);
for(i=0;i<4;i++)
{printf("%2.2X%2.2X ", ch[i*2+1],ch[i*2]);}
}
// ------------- end of transmission -----------------