// Remove // of the next line if you want to test this module. //#define testMBnhash // main() in this module will be used (-> MB192hash is // tested). In this case, do not change any lines below. /***** Select a hash-type *****/ //#define MB64hash //#define MB192hash //#define MB256hash //#define MB384hash //#define MB512hash //#define MB1024hash //#define MB2048hash //#define MB4096hash #ifdef testMBnhash #define MB192hash #endif /******************/ #include #include #ifdef MB64hash #define HS_name "MB64DI4A" #endif #ifdef MB192hash #define HS_name "MB192DI4A" #endif #ifdef MB256hash #define HS_name "MB256DI4A" #endif #ifdef MB384hash #define HS_name "MB384DI4A" #endif #ifdef MB512hash #define HS_name "MB512DI4A" #endif #ifdef MB1024hash #define HS_name "MB1024DI4A" #endif #ifdef MB2048hash #define HS_name "MB2048DI4A" #endif #ifdef MB4096hash #define HS_name "MB4096DI4A" #endif /******************************/ #define HSBufSize 1024 #define mIntMSB 0x8000000000000000 #define mIntBaseM1 0xffffffffffffffff #define mIntBaseBits 64 #ifdef MB64hash #define HSHashBitSize 64 // L=8(byte)(must be int64 size) #define HScompXsizeByte 4 // M=4(byte) #define HSCharsInOneComp 2 // E=2(byte) #define HScompEPosByte 2 // P=2(byte)(pos. starting from 1) #define HSshiftByteInOneComp 1 // D=1(byte) int HSscrYsizeByte = 4; // Q=4(byte) int HSscrBitShiftSize = 6; // S=6/8(byte) int HSscrBitShiftTimes = 16; int HSHashBgnBit = 16; // Q/2(byte) //----------------------------// #define mIntLLISize 2 #define mIntIndexMin 1 #define mIntIndexMax 1 //----------------------------// #endif #ifdef MB192hash #define HSHashBitSize 192 // L=24(byte)(must be int64 size) #define HScompXsizeByte 8 // M=8(byte) #define HSCharsInOneComp 8 // E=8(byte) #define HScompEPosByte 5 // P=5(byte)(pos. starting from 1) #define HSshiftByteInOneComp 4 // D=4(byte) int HSscrYsizeByte = 12; // Q=12(byte) //MBnhashDI int HSscrBitShiftSize = 16; // S=2(byte) int HSscrBitShiftTimes = 16; int HSHashBgnBit = 32; // not Q/2(byte) //----------------------------// #define mIntLLISize 4 #define mIntIndexMin 1 #define mIntIndexMax 3 //----------------------------// #endif #ifdef MB256hash #define HSHashBitSize 256 // L=32(byte)(must be int64 size) #define HScompXsizeByte 8 // M=8(byte) #define HSCharsInOneComp 8 // E=8(byte) #define HScompEPosByte 5 // P=5(byte)(pos. starting from 1) #define HSshiftByteInOneComp 4 // D=4(byte) int HSscrYsizeByte = 12; // Q=12(byte) //MBnhashDI int HSscrBitShiftSize = 24; // S=3(byte) int HSscrBitShiftTimes = 16; int HSHashBgnBit = 32; // not Q/2(byte) //----------------------------// #define mIntLLISize 5 #define mIntIndexMin 1 #define mIntIndexMax 4 //----------------------------// #endif #ifdef MB384hash #define HSHashBitSize 384 // L=48(byte)(must be int64 size) #define HScompXsizeByte 12 // M=12(byte) #define HSCharsInOneComp 16 // E=16(byte) #define HScompEPosByte 9 // P=9(byte)(pos. starting from 1) #define HSshiftByteInOneComp 8 // D=8(byte) int HSscrYsizeByte = 12; // Q=12(byte) int HSscrBitShiftSize = 32; // S=4(byte) int HSscrBitShiftTimes = 16; int HSHashBgnBit = 48; // Q/2(byte) //----------------------------// #define mIntLLISize 7 #define mIntIndexMin 1 #define mIntIndexMax 6 //----------------------------// #endif #ifdef MB512hash #define HSHashBitSize 512 // L=64(byte)(must be int64 size) #define HScompXsizeByte 12 // M=12(byte) #define HSCharsInOneComp 16 // E=16(byte) #define HScompEPosByte 9 // P=9(byte)(pos. starting from 1) #define HSshiftByteInOneComp 8 // D=8(byte) int HSscrYsizeByte = 16; // Q=16(byte) int HSscrBitShiftSize = 48; // S=6(byte) int HSscrBitShiftTimes = 16; int HSHashBgnBit = 62; // Q/2(byte) //----------------------------// #define mIntLLISize 9 #define mIntIndexMin 1 #define mIntIndexMax 8 //----------------------------// #endif #ifdef MB1024hash #define HSHashBitSize 1024 // L=128(byte)(must be int64 size) #define HScompXsizeByte 20 // M=20(byte) #define HSCharsInOneComp 32 // E=32(byte) #define HScompEPosByte 17 // P=17(byte)(pos. starting from 1) #define HSshiftByteInOneComp 16 // D=16(byte) int HSscrYsizeByte = 28; // Q=28(byte) int HSscrBitShiftSize = 96; // S=12(byte) int HSscrBitShiftTimes = 16; int HSHashBgnBit = 112; // Q/2(byte) //----------------------------// #define mIntLLISize 17 #define mIntIndexMin 1 #define mIntIndexMax 16 //----------------------------// #endif #ifdef MB2048hash #define HSHashBitSize 2048 // L=256(byte)(must be int64 size) #define HScompXsizeByte 36 // M=36(byte) #define HSCharsInOneComp 64 // E=64(byte) #define HScompEPosByte 33 // P=33(byte)(pos. starting from 1) #define HSshiftByteInOneComp 32 // D=32(byte) int HSscrYsizeByte = 52; // Q=52(byte) int HSscrBitShiftSize = 192; // S=24(byte) int HSscrBitShiftTimes = 16; int HSHashBgnBit = 208; // Q/2(byte) //----------------------------// #define mIntLLISize 33 #define mIntIndexMin 1 #define mIntIndexMax 32 //----------------------------// #endif #ifdef MB4096hash #define HSHashBitSize 4096 // L=512(byte)(must be int size) #define HScompXsizeByte 68 // M=68(byte) #define HSCharsInOneComp 128 // E=128(byte) #define HScompEPosByte 65 // P=65(byte)(pos. starting from 1) #define HSshiftByteInOneComp 64 // D=64(byte) int HSscrYsizeByte = 96; // Q=96(byte) int HSscrBitShiftSize = 384; // S=48(byte) int HSscrBitShiftTimes = 16; int HSHashBgnBit = 384; // Q/2(byte) //----------------------------// #define mIntLLISize 65 #define mIntIndexMin 1 #define mIntIndexMax 64 //----------------------------// #endif //*************************************************************// typedef struct /* Intel's MPU only */ { unsigned int L; unsigned int H; } uiHL; typedef union { unsigned long long int I; uiHL HL; } uiLLHL; /********************** type def for mInt *********************/ typedef struct { unsigned long long int mIdgt[mIntLLISize]; } mInt; typedef struct { unsigned long long int mIdgt[1+mIntIndexMax*2]; } mIntD; typedef union { unsigned long long int ulli[mIntLLISize]; //unsigned int ui[mIntLLISize*sizeof(long long int)/sizeof(int)]; unsigned char uc[mIntLLISize*sizeof(long long int)]; } HS; typedef union { unsigned long long int ulli[1+mIntIndexMax*2]; //unsigned int ui[(1+mIntIndexMax*2)*sizeof(long long int)/sizeof(int)]; unsigned char uc[(1+mIntIndexMax*2)*sizeof(long long int)]; } HSD; /*=========== Inline Assembling ============*/ #ifdef _WIN64 #define INT64_PRINTF_FORMAT "I64" #else #define __int64 long long #define INT64_PRINTF_FORMAT "L" #endif typedef struct { unsigned __int64 lo64; unsigned __int64 hi64; } my_i128; //******************************** #define ADD_64_64(out, in1, in2) \ __asm__("mov %2, %%rax; \ mov %3, %%rcx; \ xorq %%rdx, %%rdx; \ addq %%rcx, %%rax; \ adcq %%rdx, %%rdx; \ mov %%rdx, %0; \ mov %%rax, %1; \ " \ : "=r"(out.hi64), "=r"(out.lo64) \ : "r"(in1), "r"(in2) \ : "%rax", "%rcx", "%rdx" \ ); //******************************** #define MUL_64_64(out, in1, in2) \ __asm__("mov %2, %%rax; \ mov %3, %%rcx; \ mul %%rcx; \ mov %%rdx, %0; \ mov %%rax, %1; \ " \ : "=r"(out.hi64), "=r"(out.lo64) \ : "r"(in1), "r"(in2) \ : "%rax", "%rcx", "%rdx" \ ); /*======== End of Inline Assembling ========*/ //******************************** int mIntMUL_HL(mInt *U, mInt *V, mIntD *UVD) { my_i128 LLHLuv, LLMulAddWk1, LLMulAddWk2; int i, j, iPj; unsigned long long int c; if (U->mIdgt[mIntIndexMin-1] != 0) {return(1);} if (V->mIdgt[mIntIndexMin-1] != 0) {return(2);} memset(UVD, 0, sizeof(mIntD)); for (j=mIntIndexMax; j>=mIntIndexMin; j--) /* V */ { if (V->mIdgt[j] == 0) { UVD->mIdgt[j] = 0; continue; } c=0; for (i=mIntIndexMax; i>=mIntIndexMin; i--) /* U */ { iPj = i+j; MUL_64_64(LLHLuv, U->mIdgt[i], V->mIdgt[j]); ADD_64_64(LLMulAddWk1, LLHLuv.lo64, UVD->mIdgt[iPj]); ADD_64_64(LLMulAddWk2, LLMulAddWk1.lo64, c); UVD->mIdgt[iPj] = LLMulAddWk2.lo64; c = LLHLuv.hi64 + LLMulAddWk1.hi64 + LLMulAddWk2.hi64; } UVD->mIdgt[j] = c; //DumpmIntD(UVD, 'm'); //debug } /* DumpmInt(U, 'u'); //debug DumpmInt(V, 'v'); //debug DumpmIntD(UVD, 'M'); //debug */ return(0); } /*==================================================*/ /*************** constant for hashing *********************/ //1.2718281828459... MSB = 1 BaseForm[N[1+E/10,1500]*8,16] unsigned long long int HSconst1_4800bits[1+2*4*9+3] = { 0, 0xa2cb4411ba257552, 0x232c1139a172a5c9, 0xf8252780c2d5d7b7, 0x88603e0d04140a65, 0x8f50b9293a8572fe, 0xb2a32d7a47027df8, 0x314d239a22f4137e, 0xf72c9fc45dff7aad, 0x073d976cac9ae2f6, 0x8113e1110c629efd, 0x8aab03dfb3118ea4, 0x51a968e3602e1be4, 0xc6ee1b9230c994e3, 0x9f96ab537155fb0a, 0xa355c20fdb3ee518, 0x8c0223808a3a98ad, 0x29ce884256f4fa65, 0x8b7bc557e02b30e1, 0x9f7640872c71dc64, 0x22de2f94ad7d589e, 0x9bce54c1c9354916, 0x860098f9f5fe6095, 0xc00a675c3b3da313, 0x837d661f61e780cc, 0xb60fd0709630804d, 0x8d993f0575afef7d, 0x725798f26fc06ccd, 0xf44fc9e7190480bd, 0x5afd753af38a2ffe, 0xe81573a4e0398ff8, 0xf93ddf0be10500ab, 0xf270fdc631ec0071, 0xad24165b91615b67, 0xe55e9f6e1d3197fc, 0x784f56988d1af838, 0xefcc6a351a9d83b0, 0x2403cf50bf40b1da, 0x9765da76fa2b0f90, 0xadca2d3949fddbff, 0xdf561a225285fe1f, 0xc815d58dd3a47202, 0xbbf439eb1f02c892, 0x05f31eda2ac0db42, 0xcef2901598772c63, 0x0c056cfc732ab918, 0xd460d2a247b93963, 0x7c7caa270475fdcb, 0xe509c860fab4de57, 0xbc19130d5e1fe29e, 0x7e47296c4433d99a, 0x819778bab2d6c27e, 0xe371281afcbda382, 0x2f7b9f99d5ec7b3d, 0x5501799bb6b37027, 0x4927e4feb055ccd8, 0x01d51eba3d8f1be5, 0x386c583f7d0cccd8, 0xd542f621feb5cef5, 0x9bb3b6c2c2f51929, 0x82f524454cb4edaf, 0x0f8abb4397404d60, 0x5ae8667fac692b66, 0xcf32adbe0dcd7c18, 0x7614b2a271aa3ba5, 0x3a58740d5bcaa621, 0x3f2410d6ebe46dc1, 0xb6b25f7a89f365dc, 0x23e94f3d75b005a5, 0x5c55ce1198f6627d, 0x1f0645a60fa79a6c, 0xa4e6a7ff0f65f0e4, 0xbaa0e397eebb7b69, 0xbe77706fc57a402b, 0x5336301d3dcdd060, 0x9bbfc066652d86e2 }; // for HS compression HS HScompXM, HScompFM; unsigned int HSCharLenOld, HSInCharNo; // for compression int HSxorStartPosLLI, HSxorEndPosLLI, HSxorSizeLLI; int HSxorStartPosC, HSxorStartPosCrev; HS HSstoreCharsInOneComp; int HSxorClrStartPosLLIrev; int HSCmpShift_LLISize, HSCmpShift_ByteSize, HSCmpShift_ByteSizeC; /******** to debug mInt ********/ #ifdef _WIN64 #define LLINT_PRINTF_FORMAT "I64" #else #define LLINT_PRINTF_FORMAT "L" #endif void DumpMint(mInt *M, char c) { int i; printf("%c ", c); for (i=mIntIndexMin-1; i<=mIntIndexMax; i++) {printf("%016" INT64_PRINTF_FORMAT "x ", M->mIdgt[i]);} printf("\n"); } void DumpMintD(mIntD *MD, char c) { int i; printf("%c ", c); for (i=mIntIndexMin-1; i<=mIntIndexMax*2; i++) {printf("%016" INT64_PRINTF_FORMAT "x ", MD->mIdgt[i]);} printf("\n"); } /*===============================================================*/ /*****************/ void MBhashInit(void) { int HScompXsizeLLI, HScompXsizeByteRmdr, wk; unsigned long long int ulliWk; int InitValBytes; int A=sizeof(mInt), B=sizeof(HSconst1_4800bits); if (A>B) {InitValBytes=B;} else {InitValBytes=A;} memset(&HScompFM, 0, sizeof(mInt)); memcpy(&HScompFM, HSconst1_4800bits, InitValBytes); //DumpMint((mInt *)&HScompFM, 'f'); //debug memset(&HScompXM, 0, sizeof(mInt)); HScompXsizeLLI = HScompXsizeByte/(mIntBaseBits/8); HScompXsizeByteRmdr = HScompXsizeByte%(mIntBaseBits/8); //printf("HScompXsizeByte : %d HScompXsizeLLI : %d HScompXsizeByteRmdr : %d\n", // HScompXsizeByte, HScompXsizeLLI, HScompXsizeByteRmdr); //debug if (HScompXsizeByteRmdr) { HScompXsizeLLI++; memcpy(&HScompXM, &HSconst1_4800bits, (HScompXsizeLLI+1)*(mIntBaseBits/8)); wk = ((mIntBaseBits/8)-HScompXsizeByteRmdr)*8; HScompXM.ulli[HScompXsizeLLI] >>= wk; HScompXM.ulli[HScompXsizeLLI] <<= HScompXsizeByteRmdr*8; ulliWk = mIntMSB; ulliWk >>= (HScompXsizeByteRmdr*8-1); HScompXM.ulli[HScompXsizeLLI] |= ulliWk; //LSB } else { memcpy(&HScompXM, &HSconst1_4800bits, (HScompXsizeLLI+1)*(mIntBaseBits/8)); HScompXM.ulli[HScompXsizeLLI] |= 1; //LSB } HScompXM.ulli[mIntIndexMin] |= mIntMSB; //MSB //DumpMint((mInt *)&HScompXM, 'x'); //debug HSxorStartPosLLI = ((HScompEPosByte-1)/(mIntBaseBits/8))+1; HSxorSizeLLI = ((HSCharsInOneComp*3)/2)/(mIntBaseBits/8); if (((HSCharsInOneComp*3)/2) % (mIntBaseBits/8)) {HSxorSizeLLI++;} HSxorEndPosLLI = HSxorStartPosLLI+HSxorSizeLLI-1; if (HSxorEndPosLLI>mIntIndexMax) {printf("HSxorEndPosLLI>mIntIndexMax\n");} HSxorStartPosC = HScompEPosByte-1+(mIntBaseBits/8); HSxorStartPosCrev = mIntLLISize*(mIntBaseBits/8) - HSxorStartPosC -1; HSxorClrStartPosLLIrev = mIntIndexMax - HSxorStartPosLLI - HSxorSizeLLI + 1; //printf("HScompEPosByte : %d HSCharsInOneComp : %d EXT-HSCharsInOneComp %d\n", // HScompEPosByte, HSCharsInOneComp, (HSCharsInOneComp*3)/2); //debug //printf("HSxorStartPosLLI : %d HSxorEndPosLLI : %d HSxorSizeLLI: %d\n", // HSxorStartPosLLI, HSxorEndPosLLI, HSxorSizeLLI); //debug //printf("HSxorStartPosC : %d HSxorStartPosCrev : %d\n", HSxorStartPosC, HSxorStartPosCrev); //debug //printf("HSxorClrStartPosLLIrev : %d HScompXsizeByte %d\n", HSxorClrStartPosLLIrev, HScompXsizeByte); //debug HSCmpShift_LLISize = HSshiftByteInOneComp/(mIntBaseBits/8); HSCmpShift_ByteSize = HSshiftByteInOneComp % (mIntBaseBits/8); HSCmpShift_ByteSizeC = (mIntBaseBits/8)- HSCmpShift_ByteSize; //printf("HSCmpShift_LLISize : %d HSCmpShift_ByteSize : %d HSCmpShift_ByteSizeC : %d\n", // HSCmpShift_LLISize, HSCmpShift_ByteSize, HSCmpShift_ByteSizeC); //debug memset(&HSstoreCharsInOneComp, 0, sizeof(mInt)); //memset(&HSstoreCharsInOneComp, 0xff, sizeof(mInt)); //debug //DumpMint((mInt *)&HSstoreCharsInOneComp, 's'); //debug HSCharLenOld=HSBufSize; HSInCharNo=0; } /*****************/ int MBhashCompress(unsigned char *HSBuf, int CharLen) { int i, j, k, p, kekka; HSD HSWkMD; int storeCharPos, mod3; if (CharLen==0) {return(1);} if (CharLen<0) { printf("Err: CharLen<0 (%d) \n", CharLen); return(2); } if (HSCharLenOld != HSBufSize) { printf("Err: Previous CharLen(%d) != HSBufSize(%d)\n", HSCharLenOld, HSBufSize); return(3); } HSCharLenOld = CharLen; for(j=0; j>(HSCmpShift_ByteSizeC*8)); } } //DumpMint((mInt *)&HScompFM, 'F'); //debug } return(0); } /****************/ int MBhashGenVal(HS *HashValueM) { int i, j, k, mIntResult; int HSBitShift_LLISize, HSBitShift_BitSizeRmdr, HSBitShift_BitSizeRmdrC; int HSHashBgnLLI, HSHashBgnBitRmdr; int scrYMucRelPos; HS scrFM, scrYM; HSD scrWk1MD; int wk1, wk2; int HScompEPosByteRmdr; unsigned long long int ulliWk1; int HSscrYsizeLLI, HSscrYsizeByteRmdr, HSscrYsizeInt, pointYIntPos; uiLLHL uiLLHL1, uiLLHL2; HSscrYsizeInt = HSscrYsizeByte/(mIntBaseBits/8); HSscrYsizeByteRmdr = HSscrYsizeByte % (mIntBaseBits/8); //HSscrYsizeInt = HSscrYsizeByte/sizeof(int); //MBhash12 //printf("HSscrYsizeByte : %d HSscrYsizeInt : %d HSscrYsizeBytreRmdr : %d\n", // HSscrYsizeByte, HSscrYsizeInt, HSscrYsizeByteRmdr); //debug memcpy(&scrFM, &HScompFM, sizeof(mInt)); //memset(&scrFM, 0x01, sizeof(mInt)); //debug //DumpMint((mInt *)&scrFM, 'f'); //debug // xor HSInCharNo //HSInCharNo = 0xf123456d; //debug ulliWk1 = HSInCharNo; HScompEPosByteRmdr = ((HScompEPosByte-1)%(mIntBaseBits/8)); if (HScompEPosByteRmdr <= (sizeof(long long int)/2)) { wk1 = ((sizeof(long long int)/2)-HScompEPosByteRmdr)*8; if (wk1) {ulliWk1 <<= wk1;} scrFM.ulli[HSxorStartPosLLI] ^= ulliWk1; } else { wk1 = (HScompEPosByteRmdr - (sizeof(long long int)/2))*8; ulliWk1 >>= wk1; scrFM.ulli[HSxorStartPosLLI] ^= ulliWk1; ulliWk1 = HSInCharNo; wk2 = ((sizeof(long long int)+sizeof(long long int)/2) - HScompEPosByteRmdr)*8; ulliWk1 <<= wk2; scrFM.ulli[HSxorStartPosLLI+1] ^= ulliWk1; } //DumpMint((mInt *)&scrFM, 'g'); //debug // prepare scrYM memset(&scrYM, 0, sizeof(mInt)); //memset(&scrFM, 0x01, sizeof(mInt)); //debug //DumpMint((mInt *)&scrYM, 'Y'); //debug //DumpMint((mInt *)&scrFM, 'F'); //debug if (HSscrYsizeByteRmdr==0) { //for (i=0; i=HSscrYsizeByte) {scrYMucRelPos=0;} if (k>= wk2; scrYM.ulli[mIntIndexMin+HSscrYsizeInt] |= 1; //LSB (HSscrYsizeByteRmdr!=0) scrYM.ulli[mIntIndexMin+HSscrYsizeInt] <<= wk2; } //DumpMint((mInt *)&scrYM, 'y'); //debug //memset(&scrYM, 0, sizeof(mInt)); //debug scrYM.ulli[mIntIndexMin] |= mIntMSB; //scrYM.ulli[HSscrYsizeInt] |= 1; //LSB (HSscrYsizeByteRmdr=0) //DumpMint((mInt *)&scrYM, 'Y'); //debug // scramble main HSBitShift_LLISize = HSscrBitShiftSize / mIntBaseBits; HSBitShift_BitSizeRmdr = HSscrBitShiftSize % mIntBaseBits; HSBitShift_BitSizeRmdrC = mIntBaseBits-HSBitShift_BitSizeRmdr; //printf("HSBitShift_LLISize : %d HSBitShift_BitSizeRmdr : %d\n", // HSBitShift_LLISize, HSBitShift_BitSizeRmdr); //debug //printf("HSBitShift_BitSizeRmdrC : %d\n", HSBitShift_BitSizeRmdrC); //debug for (i=1; i<=HSscrBitShiftTimes; i++) //for (i=1; i<=1; i++) //debug { //memset(&scrFM, 0, sizeof(mInt)); //debug scrFM.ulli[mIntIndexMin] |= mIntMSB; scrFM.ulli[mIntIndexMax] |= 1; //DumpMint((mInt *)&scrFM, 'f'); //debug mIntResult = mIntMUL_HL((mInt *)&scrFM, (mInt *)&scrYM, (mIntD *)&scrWk1MD); if (mIntResult != 0) {return(3000+mIntResult);} //DumpMintD((mIntD *)&scrWk1MD, 'D'); //debug for (j=1; j<=mIntIndexMax; j++) { if (HSBitShift_BitSizeRmdr==0) { scrFM.ulli[j] = scrWk1MD.ulli[j+HSBitShift_LLISize]; } else { scrFM.ulli[j] = (scrWk1MD.ulli[j+HSBitShift_LLISize]<>HSBitShift_BitSizeRmdrC); } } //DumpMint((mInt *)&scrFM, 'F'); //debug } //DumpMint((mInt *)&scrFM, 'F'); //debug // take out random number //DumpMintD((mIntD *)&scrWk1MD, 'D'); //debug HSHashBgnLLI = HSHashBgnBit/mIntBaseBits; HSHashBgnBitRmdr = HSHashBgnBit % mIntBaseBits; //printf("HSHashBgnBit : %d HSHashBgnLLI : %d HSHashBgnBitRmdr : %d\n", // HSHashBgnBit, HSHashBgnLLI, HSHashBgnBitRmdr); //debug for (j=1; j<=mIntIndexMax; j++) { if (HSHashBgnBitRmdr==0) { HashValueM->ulli[j] = scrWk1MD.ulli[j+HSHashBgnLLI]; } else { HashValueM->ulli[j] = (scrWk1MD.ulli[HSHashBgnLLI+j] << HSHashBgnBitRmdr); HashValueM->ulli[j] |= (scrWk1MD.ulli[HSHashBgnLLI+j+1] >> (mIntBaseBits-HSHashBgnBitRmdr)); } } HashValueM->ulli[mIntIndexMin-1]=0; //DumpMint((mInt *)HashValueM, 'H'); //debug return(0); } /********************* testMBnhash ***********************/ // MBnnnhash should be used such as // // unsigned char Msg_Buf[HSBufSize] // HSBufSize=1024 // HS HashValue; // store hash value // // MBhashInit(); //initialize MBhash // MBhashCompress(Msg_Buf, HSBufSize); //send data to MBhash // ..... // MBhashCompress(Msg_Buf, HSBufSize); // MBhashCompress(Msg_Buf, kk); // 0 < kk <= HSBufSize // MBhashGenVal(&HashValue); //generate a hash value #ifdef testMBnhash int main() { int i; unsigned char Msg_Buf[HSBufSize] = "01234567"; // HSBufSize=1024 HS HashValue; for (i=8; i