Skip to content

Commit c65951f

Browse files
committed
Version 2.0.2
1 parent 1dd69fa commit c65951f

14 files changed

+81
-51
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
Changelog
22

3+
Mon Sep 21 18:33:00 MSK 2009
4+
----------------------------
5+
V 2.0.2
6+
* Bug:
7+
- ignore parameter in commandline when pass length=1
8+
39
Thu Aug 14 17:45:00 MSK 2007
410
----------------------------
511
V 2.0.1

INSTALL

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11

2-
Prepare:
3-
Fix values in test.ini (unix and win32 - different path and extensions)
4-
52
Compile and install wmsigner is easy:
63

74
$ make
8-
$ make test
95
$ make install
10-
11-

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PACKAGE = wmsigner
2-
VERSION = 2.0b
2+
VERSION = 2.0.1
33
SHELL = /bin/sh
44

55
PREFIX = ${prefix}/usr/local

README.rus

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
README.rus
1+
2+
*** ВНИМАНИЕ ***
3+
4+
Если Вы используете язык программирования отличный от shell(bash), то имеет смысл
5+
обратить внимание на библиотеки с поддержкой используемого языка:
6+
http://wiki.webmoney.ru/wiki/show/WMSigner
7+
8+
****************
9+
10+
211

312
Модуль wmsigner предназначен для генерации подписи произвольной строки.
413
Подробнее вы можете узнать об этом на странице
514
http://www.webmoney.ru/rus/developers/interfaces/xml/authdescr/wmsigner.shtml
615

16+
17+
718
Для компиляции выполните команду
819
$ make
920
в результате чего будет создан модуль wmsigner и модуль code64.

RUNNING_TESTS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
1. Fix values in test.ini (unix and win32 - different path and extensions)
3+
2. Run:
4+
$ make
5+
$ make test

base64.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* .........................................................................................................................
2020
* This module present "AS IS", absolutely no warranty, if anybody modyfied this source.
2121
****************************************************************************************************************************/
22+
23+
#include "stdafx.h"
2224
#include "base64.h"
2325

2426
/* Base_64 characters */
@@ -141,4 +143,5 @@ int idx64( char ch )
141143
/* Illegal character found, task aborted ! */
142144
fprintf( stderr, "\n\rBase64 Fatal Error: Illegal character found : '%c' [%d] - No Base64 legal character!!\n\r", ch, ch );
143145
exit(1);
146+
return(0);
144147
}

cmdbase.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ szptr& szptr::operator = (const szptr& cszptr)
111111

112112
szptr& szptr::operator += (const szptr& cszptr)
113113
{
114-
if(!&cszptr) return *this;
114+
// if(!&cszptr) return *this;
115115
if(!cszptr.strlen()) return *this;
116116

117117
char *szprev = sz;
@@ -238,17 +238,17 @@ DWORD Keys::GetMembersSize()
238238
char *Keys::LoadMembers(char *BufPtr)
239239
{
240240
char *ptrNextMemb = dwordFromBuf(&dwReserv, BufPtr);
241-
241+
unsigned int i = 0;
242242
ptrNextMemb = wordFromBuf(&wEKeyBase, ptrNextMemb);
243243
memcpy(arwEKey, ptrNextMemb, wEKeyBase);
244-
for(WORD i=0;i<wEKeyBase/sizeof(arwEKey[0]);i++)
244+
for( i=0;i<wEKeyBase/sizeof(arwEKey[0]);i++)
245245
{ arwEKey[i] = SwitchIndian(arwEKey[i]); }
246246

247247
ptrNextMemb += wEKeyBase;
248248

249249
ptrNextMemb = wordFromBuf(&wNKeyBase, ptrNextMemb);
250250
memcpy(arwNKey, ptrNextMemb, wNKeyBase);
251-
for(unsigned int i=0;i<wNKeyBase/sizeof(arwNKey[0]);i++)
251+
for( i=0;i<wNKeyBase/sizeof(arwNKey[0]);i++)
252252
{ arwNKey[i] = SwitchIndian(arwNKey[i]); }
253253

254254
ptrNextMemb += wNKeyBase;
@@ -260,12 +260,12 @@ char *Keys::SaveMembers(char *BufPtr)
260260
{
261261
char *ptrNextMemb = dwordToBuf(BufPtr, dwReserv);
262262

263-
wEKeyBase = GetKeyBaseB(arwEKey);
263+
wEKeyBase = (WORD)GetKeyBaseB(arwEKey);
264264
ptrNextMemb = wordToBuf(ptrNextMemb, wEKeyBase);
265265
memcpy(ptrNextMemb, arwEKey, wEKeyBase);
266266
ptrNextMemb += wEKeyBase;
267267

268-
wNKeyBase = GetKeyBaseB(arwNKey);
268+
wNKeyBase = (WORD)GetKeyBaseB(arwNKey);
269269
ptrNextMemb = wordToBuf(ptrNextMemb, wNKeyBase);
270270
memcpy(ptrNextMemb, arwNKey, wNKeyBase);
271271
ptrNextMemb += wNKeyBase;
@@ -276,18 +276,20 @@ char *Keys::SaveMembers(char *BufPtr)
276276

277277
void Keys::RecalcBase()
278278
{
279-
wEKeyBase = GetKeyBaseB(arwEKey);
280-
wNKeyBase = GetKeyBaseB(arwNKey);
279+
wEKeyBase = (WORD)GetKeyBaseB(arwEKey);
280+
wNKeyBase = (WORD)GetKeyBaseB(arwNKey);
281281
}
282282

283283
int Keys::LoadFromBuffer(const char *Buf, DWORD dwBufLen)
284284
{
285+
KeyFileFormat *keyFmt = (KeyFileFormat *)Buf;
286+
DWORD ardwRecievedCRC[4];
287+
DWORD ardwCheckedCRC[4];
288+
DWORD i = 0;
289+
285290
if(dwBufLen < KeyFileFormat::sizeof_header)
286291
return _CMDLOAD_ERR_BUF_LEN_;
287292

288-
KeyFileFormat *keyFmt = (KeyFileFormat *)Buf;
289-
DWORD ardwRecievedCRC[4], ardwCheckedCRC[4], i;
290-
291293
if(dwBufLen-2*sizeof(DWORD) >= SwitchIndian(keyFmt->dwLenBuf))
292294
{
293295
for(i=0; i<4; i++)

code64.exe

-72 KB
Binary file not shown.

rsalib1.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
#include "rsalib1.h"
88
#include <stdio.h>
99

10+
#ifndef WORD
11+
#define WORD unsigned int
12+
#endif
13+
1014
int N_NEG_VAL=-1;
1115

1216
CRSALib::CRSALib(short glob_pres)
@@ -741,7 +745,7 @@ int CRSALib::mp_sqrt(unitptr quotient,unitptr dividend)
741745
qbitmask = ((unit) 1 << ((qbits-1) & (16-1))) ;
742746

743747
oldprecision = global_precision;
744-
(global_precision = ((((qbits+3)+15) >> 4)));
748+
(global_precision = (WORD)((((qbits+3)+15) >> 4)));
745749

746750
*(quotient) |= qbitmask;
747751
{
@@ -832,7 +836,7 @@ int CRSALib::mp_sqrt(unitptr quotient,unitptr dividend)
832836
}
833837
}
834838
notperfect = ( ((*(remainder))!=(0)) || (significance(remainder)>1) );
835-
(global_precision = (oldprecision));
839+
(global_precision = (WORD)(oldprecision));
836840
return(notperfect);
837841
}
838842
//----

rsalib1.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class CRSALib
7272
int mp_modexp(register unitptr expout,register unitptr expin,
7373
register unitptr exponent,register unitptr modulus);
7474

75-
int rsa_decrypt(unitptr M, unitptr C, unitptr d, unitptr p, unitptr q, unitptr u);
75+
int rsa_decrypt(unitptr M, unitptr C, unitptr d, unitptr p, unitptr q, unitptr u);
7676
int mp_sqrt(unitptr quotient,unitptr dividend);
7777
};
7878

signer.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@
1010
#include <sys/types.h>
1111
#include <sys/stat.h>
1212
#include <errno.h>
13-
#define __open _open
14-
#define __read _read
15-
#define __close _close
13+
#define __open open
14+
#define __read read
15+
#define __close close
1616
#else
1717
#include <sys/types.h>
1818
#include <sys/stat.h>
1919
#include <sys/uio.h>
2020
#include <unistd.h>
2121
#include <errno.h>
22-
#define __open open
23-
#define __read read
24-
#define __close close
22+
#define __open open
23+
#define __read read
24+
#define __close close
2525
#endif
2626

2727
#ifndef TRUE
28-
#define TRUE 1
28+
#define TRUE 1
2929
#endif
3030
#ifndef FALSE
31-
#define FALSE 0
31+
#define FALSE 0
3232
#endif
3333

3434
bool Signer::SecureKeyByIDPW(char *buf, DWORD dwBuf)
@@ -108,7 +108,7 @@ int Signer::LoadKeys()
108108
int errLoadKey;
109109
int fh = -1;
110110
int st_size = 0;
111-
const int nMaxBufLen = sizeof(Keys) + KeyFileFormat::sizeof_header;
111+
const int nMaxBufLen = 164;
112112
char *pBufRead = new char[nMaxBufLen]; // Here Keys must be
113113
m_siErrorCode = 0;
114114
KeyFromCL = FALSE;
@@ -122,7 +122,7 @@ if( (!isIgnoreKeyFile) && (Key64Flag == FALSE) ) {
122122

123123
if( fh == -1 )
124124
{
125-
m_siErrorCode = errno;
125+
m_siErrorCode = 2;//errno;
126126
return false;
127127
}
128128

@@ -197,7 +197,7 @@ bool Signer::Sign(const char *szIn, szptr& szSign)
197197
{
198198
DWORD dwCRC[14];
199199
#ifdef _DEBUG
200-
printf("\n\rSign - Start !");
200+
printf("\n\rSign - Start !");
201201
#endif
202202

203203
if (!LoadKeys())
@@ -206,7 +206,7 @@ bool Signer::Sign(const char *szIn, szptr& szSign)
206206
return false;
207207
}
208208
#ifdef _DEBUG
209-
printf("\n\rSign - Load Keys");
209+
printf("\n\rSign - Load Keys");
210210
#endif
211211

212212
if(!keys.wEKeyBase || !keys.wNKeyBase)
@@ -242,31 +242,31 @@ bool Signer::Sign(const char *szIn, szptr& szSign)
242242
{ printf("packing%d: %x\n", h, ((char*)dwCRC)[h]); }
243243
#endif
244244
#ifdef _DEBUG
245-
printf("\n\rCalling CrpB() - start");
245+
printf("\n\rCalling CrpB() - start");
246246
#endif
247247
CrpB(ptrCrpBlock, (char *)dwCRC, sizeof(dwCRC), keys.arwEKey, keys.arwNKey);
248248
#ifdef _DEBUG
249-
printf("\n\rCalling CrpB() - end");
249+
printf("\n\rCalling CrpB() - end");
250250
#endif
251251
char *charCrpBlock = new char[dwCrpSize*2+1];
252252
us2sz((const unsigned short *)ptrCrpBlock, dwCrpSize/2, charCrpBlock);
253253
szSign = charCrpBlock;
254254
#ifdef _DEBUG
255-
printf("\n\rSign - prepare end");
255+
printf("\n\rSign - prepare end");
256256
#endif
257257

258258
delete [] charCrpBlock;
259259
delete [] ptrCrpBlock;
260260

261261
#ifdef _DEBUG
262-
printf("\n\rSign - end return true");
262+
printf("\n\rSign - end return true");
263263
#endif
264264

265265
return true;
266266
}
267267

268268
#ifdef _DEBUG
269-
printf("\n\rSign - end return false");
269+
printf("\n\rSign - end return false");
270270
#endif
271271
return false;
272272
}
@@ -283,7 +283,7 @@ int Signer2::LoadKeys()
283283
int errLoadKey;
284284

285285
int nStrKeyDataLen = m_strKeyData.strlen();
286-
const int nMaxBufLen = sizeof(Keys) + KeyFileFormat::sizeof_header;
286+
const int nMaxBufLen = 164;
287287
if ((nStrKeyDataLen>0) && (nStrKeyDataLen < nMaxBufLen*2))
288288
{
289289
BYTE *bKeyData = new BYTE[nMaxBufLen];

wmsigner.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
#include "cmdbase.h"
88

99
#ifndef ENCODE
10-
#define ENCODE 0
10+
#define ENCODE 0
1111
#endif
1212

1313
#ifndef DECODE
14-
#define DECODE 1
14+
#define DECODE 1
1515
#endif
1616

1717
#ifndef CODE_ERR
18-
#define CODE_ERR 0
18+
#define CODE_ERR 0
1919
#endif
2020

21-
const char* WMSignerVersion = "2.0b";
21+
const char* WMSignerVersion = "2.0.1";
2222
bool isIgnoreKeyFile = false;
2323
bool isIgnoreIniFile = false;
2424
bool isKWMFileFromCL = false;
@@ -32,6 +32,7 @@ int CommandLineParse( const int argc, const char *argv[], char *szLoginCL, char
3232
void NormStr( char *str );
3333
int fatal_err( char *err_msg );
3434
int ReadConsoleString( char *str );
35+
int main(int argc, char* argv[]);
3536

3637
/***********************************/
3738

@@ -269,16 +270,17 @@ int main(int argc, char* argv[])
269270
/* Replace Key File Name from command Line, if present */
270271
if( strlen(szFileNameCL) ) szIniFileFull = szFileNameCL;
271272

272-
if( ((Key64Flag == TRUE) || (isKWMFileFromCL == true)) && (strlen(szLoginCL) > 1) && (strlen(szPwdCL) > 1))
273-
isIgnoreIniFile = true;
273+
if( ((Key64Flag == TRUE) || (isKWMFileFromCL == true)) && (strlen(szLoginCL) > 1) && (strlen(szPwdCL) >= 1))
274+
isIgnoreIniFile = true;
274275

275276
// loading ini-file
276277
if( isIgnoreIniFile == false )
277278
if (!LoadIniFile(szIniFileFull, szLogin, szPwd, szFileName, siErrCode))
278279
{
279280
sprintf(szError, "Error %d", siErrCode);
280281
printf(szError);
281-
return 2;
282+
exit(2);
283+
// return 2;
282284
}
283285

284286
// Replace Login and Password from command Line, if present
@@ -320,9 +322,9 @@ int main(int argc, char* argv[])
320322

321323

322324
if ( result ){
323-
strncpy( pszOut, szSign, MAXSTR);
325+
strncpy( pszOut, szSign, MAXSTR);
324326
printf("%s", pszOut);
325-
exit(0);
327+
exit(0);
326328
}
327329
else {
328330
sprintf(pszOut, "Error %d", ErrorCode );
@@ -347,11 +349,12 @@ int ReadConsoleString( char *str )
347349
}
348350
str[i++] = (char) ch;
349351
}
350-
return( 0 );
352+
//return( 0 );
351353
}
352354

353355
int fatal_err( char *err_msg )
354356
{
355357
printf( "%s", err_msg);
356358
exit(1);
359+
return(0);
357360
}

wmsigner.exe

-88 KB
Binary file not shown.

wmsigner.spec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Summary: wmsigner module for Webmoney signing data
22
Name: wmsigner
3-
Version: 2.0.1
3+
Version: 2.0.2
44
Release: 1
55
Group: Applications/Tools
66
License: BSD
@@ -35,6 +35,8 @@ make install prefix=%{buildroot}
3535
%attr(0644, root, bin) /usr/share/doc/wmsigner/README.rus
3636

3737
%changelog
38+
* Mon Sep 21 2009 Alexander Oryol <[email protected]> 2.0.2
39+
- update to 2.0.2
3840
* Thu Aug 14 2007 Alexander Oryol <[email protected]> 2.0.1
3941
- update to 2.0.1
4042
* Mon Jul 23 2007 Alexander Oryol <[email protected]> 2.0

0 commit comments

Comments
 (0)