activelock-development Mailing List for ActiveLock (Page 22)
Brought to you by:
ialkan
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(5) |
Jul
(52) |
Aug
(170) |
Sep
(34) |
Oct
(62) |
Nov
(46) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(7) |
Feb
(2) |
Mar
|
Apr
(17) |
May
(14) |
Jun
(31) |
Jul
(59) |
Aug
(18) |
Sep
(3) |
Oct
|
Nov
|
Dec
(5) |
2005 |
Jan
|
Feb
(10) |
Mar
(3) |
Apr
(4) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Thanh H. T. <th...@us...> - 2003-07-28 01:04:17
|
Update of /cvsroot/activelock/alcrypto/test In directory sc8-pr-cvs1:/tmp/cvs-serv28472/test Log Message: Directory /cvsroot/activelock/alcrypto/test added to the repository |
From: Thanh H. T. <th...@us...> - 2003-07-28 01:01:06
|
Update of /cvsroot/activelock/alcrypto In directory sc8-pr-cvs1:/tmp/cvs-serv28000 Added Files: ALCrypto.def ALCrypto.dsp ALCrypto.dsw BIGNUM.C CRYPT.H INT64.H MD5.C MISC.C MISC.H NOISE.C PRIME.C RAND.C RSA.C RSA.h RSAG.C SHA.C SSH.C StdAfx.cpp StdAfx.h Log Message: ActiveLock Cryptographic Library --- NEW FILE: ALCrypto.def --- ; Sample Export definition file to create Microsoft Visual C++ (Win32) ; compatible LIB file for ALCRYPTO.DLL. ; LIBRARY "ALCrypto" DESCRIPTION "ActiveLock Cryptographic Library" EXPORTS fnRSA @1 rsa_generate @2 rsa_decrypt @3 rsa_encrypt @4 rsa_public_key_blob @5 rsa_private_key_blob @6 rsa_createkey @7 rsa_sign @8 rsa_verifysig @9 rsa_freekey @10 --- NEW FILE: ALCrypto.dsp --- # Microsoft Developer Studio Project File - Name="ALCrypto" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=ALCrypto - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "ALCrypto.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "ALCrypto.mak" CFG="ALCrypto - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "ALCrypto - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "ALCrypto - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "ALCrypto - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ALCRYPTO_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ALCRYPTO_EXPORTS" /FR /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x1009 /d "NDEBUG" # ADD RSC /l 0x1009 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Cmds=copy release\alcrypto.dll test\ # End Special Build Tool !ELSEIF "$(CFG)" == "ALCrypto - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "ALCrypto___Win32_Debug" # PROP BASE Intermediate_Dir "ALCrypto___Win32_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ALCRYPTO_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ALCRYPTO_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x1009 /d "_DEBUG" # ADD RSC /l 0x1009 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Cmds=copy debug\alcrypto.dll test\ # End Special Build Tool !ENDIF # Begin Target # Name "ALCrypto - Win32 Release" # Name "ALCrypto - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\ALCRYPTO.DEF # End Source File # Begin Source File SOURCE=.\BIGNUM.C # End Source File # Begin Source File SOURCE=.\MD5.C # End Source File # Begin Source File SOURCE=.\MISC.C # End Source File # Begin Source File SOURCE=.\NOISE.C # End Source File # Begin Source File SOURCE=.\PRIME.C # End Source File # Begin Source File SOURCE=.\RAND.C # End Source File # Begin Source File SOURCE=.\RSA.C # End Source File # Begin Source File SOURCE=.\RSAG.C # End Source File # Begin Source File SOURCE=.\SHA.C # End Source File # Begin Source File SOURCE=.\StdAfx.cpp # ADD CPP /Yc"stdafx.h" # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\CRYPT.H # End Source File # Begin Source File SOURCE=.\INT64.H # End Source File # Begin Source File SOURCE=.\MISC.H # End Source File # Begin Source File SOURCE=.\RSA.h # End Source File # Begin Source File SOURCE=.\StdAfx.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\ReadMe.txt # End Source File # End Target # End Project --- NEW FILE: ALCrypto.dsw --- Microsoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "ALCrypto"=.\ALCrypto.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### --- NEW FILE: BIGNUM.C --- /** * ActiveLock Cryptographic Library * Copyright 2003 The ActiveLock Software Group (ASG) * Portions Copyright by Simon Tatham and the PuTTY project. * * All material is the property of the contributing authors. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * [o] Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * [o] Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * [...1048 lines suppressed...] workspace[i] = (BignumInt) (carry / 10); if (workspace[i]) iszero = 0; carry %= 10; } ret[--ndigit] = (char) (carry + '0'); } while (!iszero); /* * There's a chance we've fallen short of the start of the * string. Correct if so. */ if (ndigit > 0) memmove(ret, ret + ndigit, ndigits - ndigit); /* * Done. */ return ret; } --- NEW FILE: CRYPT.H --- /** * ActiveLock Cryptographic Library * Copyright 2003 The ActiveLock Software Group (ASG) * Portions Copyright by Simon Tatham and the PuTTY project. * * All material is the property of the contributing authors. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * [o] Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * [o] Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * PuTTY License * ============= * * PuTTY is copyright 1997-2001 Simon Tatham. * * Portions copyright Robert de Bath, Joris van Rantwijk, Delian * Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry, * Justin Bradford, and CORE SDI S.A. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation files * (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #ifndef ALCRYPTO_CRYPT_H #define ALCRYPTO_CRYPT_H #endif #include <string.h> #include <stdio.h> /* for FILENAME_MAX */ #include "stdafx.h" #include "misc.h" #include "int64.h" #include "rsa.h" /* * Useful thing. */ #ifndef lenof #define lenof(x) ( (sizeof((x))) / (sizeof(*(x)))) #endif #define SSH_CIPHER_IDEA 1 #define SSH_CIPHER_DES 2 #define SSH_CIPHER_3DES 3 #define SSH_CIPHER_BLOWFISH 6 #ifdef MSCRYPTOAPI #define APIEXTRA 8 #else #define APIEXTRA 0 #endif struct dss_key { Bignum p, q, g, y, x; }; int makekey(unsigned char *data, struct RSAKey *result, unsigned char **keystr, int order); int makeprivate(unsigned char *data, struct RSAKey *result); void rsasign(unsigned char *data, int length, struct RSAKey *key); void rsasanitise(struct RSAKey *key); int rsastr_len(struct RSAKey *key); void rsastr_fmt(char *str, struct RSAKey *key); void rsa_fingerprint(char *str, int len, struct RSAKey *key); int rsa_verify(struct RSAKey *key); /* externally accessible prototypes */ unsigned char *rsa_public_blob(struct RSAKey *key, int *len); void rsaencrypt(int type, unsigned char *data, int *length, struct RSAKey *key); Bignum rsadecrypt(int type, Bignum input, struct RSAKey *key); int ssh1_read_bignum(const unsigned char *data, Bignum * result); int ssh1_write_bignum(void *data, Bignum bn); Bignum bignum_from_bytes(const unsigned char *data, int nbytes); void bignum_to_bytes(Bignum bn, unsigned char *data); int rsa2_public_blob_len(void *key); void rsa2_public_blob(void *key, unsigned char *blob); int rsa2_private_blob_len(void *key); void rsa2_private_blob(void *key, unsigned char *blob); void rsa2_createkey(unsigned char *pub_blob, int pub_len, unsigned char *priv_blob, int priv_len, struct RSAKey *key); int rsa_public_blob_len(void *data); void freersakey(struct RSAKey *key); typedef unsigned int word32; typedef unsigned int uint32; unsigned long crc32(const void *s, size_t len); unsigned long crc32_update(unsigned long crc_input, const void *s, size_t len); /* SSH CRC compensation attack detector */ int detect_attack(unsigned char *buf, uint32 len, unsigned char *IV); typedef struct { uint32 h[4]; } MD5_Core_State; struct MD5Context { #ifdef MSCRYPTOAPI unsigned long hHash; #else MD5_Core_State core; unsigned char block[64]; int blkused; uint32 lenhi, lenlo; #endif }; void MD5Init(struct MD5Context *context); void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len); void MD5Final(unsigned char digest[16], struct MD5Context *context); typedef struct { uint32 h[5]; unsigned char block[64]; int blkused; uint32 lenhi, lenlo; } SHA_State; void SHA_Init(SHA_State * s); void SHA_Bytes(SHA_State * s, void *p, int len); void SHA_Final(SHA_State * s, unsigned char *output); void SHA_Simple(void *p, int len, unsigned char *output); void hmac_sha1_simple(void *key, int keylen, void *data, int datalen, unsigned char *output); typedef struct { uint64 h[8]; unsigned char block[128]; int blkused; uint32 len[4]; } SHA512_State; void SHA512_Init(SHA512_State * s); void SHA512_Bytes(SHA512_State * s, const void *p, int len); void SHA512_Final(SHA512_State * s, unsigned char *output); void SHA512_Simple(const void *p, int len, unsigned char *output); struct ssh_cipher { void (*sesskey) (unsigned char *key); /* for ssh 1 */ void (*encrypt) (unsigned char *blk, int len); void (*decrypt) (unsigned char *blk, int len); int blksize; }; struct ssh2_cipher { void (*setcsiv) (unsigned char *key); /* for ssh 2 */ void (*setcskey) (unsigned char *key); /* for ssh 2 */ void (*setsciv) (unsigned char *key); /* for ssh 2 */ void (*setsckey) (unsigned char *key); /* for ssh 2 */ void (*encrypt) (unsigned char *blk, int len); void (*decrypt) (unsigned char *blk, int len); char *name; int blksize; int keylen; }; struct ssh2_ciphers { int nciphers; const struct ssh2_cipher *const *list; }; struct ssh_mac { void (*setcskey) (unsigned char *key); void (*setsckey) (unsigned char *key); void (*generate) (unsigned char *blk, int len, unsigned long seq); int (*verify) (unsigned char *blk, int len, unsigned long seq); char *name; int len; }; struct ssh_kex { /* * Plugging in another KEX algorithm requires structural chaos, * so it's hard to abstract them into nice little structures * like this. Hence, for the moment, this is just a * placeholder. I claim justification in the fact that OpenSSH * does this too :-) */ char *name; }; struct ssh_signkey { void *(*newkey) (char *data, int len); void (*freekey) (void *key); char *(*fmtkey) (void *key); unsigned char *(*public_blob) (void *key, int *len); unsigned char *(*private_blob) (void *key, int *len); void *(*createkey) (unsigned char *pub_blob, int pub_len, unsigned char *priv_blob, int priv_len); void *(*openssh_createkey) (unsigned char **blob, int *len); int (*openssh_fmtkey) (void *key, unsigned char *blob, int len); char *(*fingerprint) (void *key); int (*verifysig) (void *key, char *sig, int siglen, char *data, int datalen); unsigned char *(*sign) (void *key, char *data, int datalen, int *siglen); char *name; char *keytype; /* for host key cache */ }; struct ssh_compress { char *name; void (*compress_init) (void); int (*compress) (unsigned char *block, int len, unsigned char **outblock, int *outlen); void (*decompress_init) (void); int (*decompress) (unsigned char *block, int len, unsigned char **outblock, int *outlen); int (*disable_compression) (void); }; struct ssh2_userkey { const struct ssh_signkey *alg; /* the key algorithm */ void *data; /* the key data */ char *comment; /* the key comment */ }; extern const struct ssh_cipher ssh_3des; extern const struct ssh_cipher ssh_des; extern const struct ssh_cipher ssh_blowfish_ssh1; extern const struct ssh2_ciphers ssh2_3des; extern const struct ssh2_ciphers ssh2_des; extern const struct ssh2_ciphers ssh2_aes; extern const struct ssh2_ciphers ssh2_blowfish; extern const struct ssh_kex ssh_diffiehellman; extern const struct ssh_kex ssh_diffiehellman_gex; extern const struct ssh_signkey ssh_dss; extern const struct ssh_signkey ssh_rsa; extern const struct ssh_mac ssh_md5; extern const struct ssh_mac ssh_sha1; extern const struct ssh_mac ssh_sha1_buggy; #ifndef MSCRYPTOAPI void SHATransform(word32 * digest, word32 * data); #endif int random_byte(void); void random_add_noise(void *noise, int length); void random_add_heavynoise(void *noise, int length); void logevent(char *); #ifdef _DEBUG void diagbn(char *prefix, Bignum md); #endif Bignum copybn(Bignum b); Bignum bn_power_2(int n); void bn_restore_invariant(Bignum b); Bignum bignum_from_long(unsigned long n); void freebn(Bignum b); Bignum modpow(Bignum base, Bignum exp, Bignum mod); Bignum modmul(Bignum a, Bignum b, Bignum mod); void decbn(Bignum n); extern Bignum Zero, One; int bignum_bitcount(Bignum bn); int ssh1_bignum_length(Bignum bn); int ssh2_bignum_length(Bignum bn); int bignum_byte(Bignum bn, int i); int bignum_bit(Bignum bn, int i); void bignum_set_bit(Bignum bn, int i, int value); Bignum biggcd(Bignum a, Bignum b); unsigned short bignum_mod_short(Bignum number, unsigned short modulus); Bignum bignum_add_long(Bignum number, unsigned long addend); Bignum bigmul(Bignum a, Bignum b); Bignum bigmuladd(Bignum a, Bignum b, Bignum addend); Bignum bigdiv(Bignum a, Bignum b); Bignum bigmod(Bignum a, Bignum b); Bignum modinv(Bignum number, Bignum modulus); Bignum bignum_bitmask(Bignum number); Bignum bignum_rshift(Bignum number, int shift); int bignum_cmp(Bignum a, Bignum b); char *bignum_decimal(Bignum x); void des3_decrypt_pubkey(unsigned char *key, unsigned char *blk, int len); void des3_encrypt_pubkey(unsigned char *key, unsigned char *blk, int len); void des3_decrypt_pubkey_ossh(unsigned char *key, unsigned char *iv, unsigned char *blk, int len); void des3_encrypt_pubkey_ossh(unsigned char *key, unsigned char *iv, unsigned char *blk, int len); void aes256_encrypt_pubkey(unsigned char *key, unsigned char *blk, int len); void aes256_decrypt_pubkey(unsigned char *key, unsigned char *blk, int len); /* * For progress updates in the key generation utility. */ #define PROGFN_INITIALISE 1 #define PROGFN_LIN_PHASE 2 #define PROGFN_EXP_PHASE 3 #define PROGFN_PHASE_EXTENT 4 #define PROGFN_READY 5 #define PROGFN_PROGRESS 6 typedef void (__stdcall *progfn_t) (void *param, int action, int phase, int progress); ALCRYPTO_API LRESULT WINAPI rsa_generate(struct RSAKey *key, int bits, progfn_t pfn, void *pfnparam); int dsa_generate(struct dss_key *key, int bits, progfn_t pfn, void *pfnparam); Bignum primegen(int bits, int modulus, int residue, Bignum factor, int phase, progfn_t pfn, void *pfnparam); /* * zlib compression. */ void zlib_compress_init(void); void zlib_decompress_init(void); int zlib_compress_block(unsigned char *block, int len, unsigned char **outblock, int *outlen); int zlib_decompress_block(unsigned char *block, int len, unsigned char **outblock, int *outlen); /* * Need this to warn about support for the original SSH2 keyfile * format. */ void old_keyfile_warning(void); #define REG_HOME "Software\\ActiveLock Software Group\\ActiveLock" #define GLOBAL extern /* Three attribute types: * The ATTRs (normal attributes) are stored with the characters in the main * display arrays * * The TATTRs (temporary attributes) are generated on the fly, they can overlap * with characters but not with normal attributes. * * The LATTRs (line attributes) conflict with no others and only have one * value per line. But on area clears the LATTR cells are set to the erase_char * (or DEFAULT_ATTR + 'E') * * ATTR_INVALID is an illegal colour combination. */ #define TATTR_ACTCURS 0x4UL /* active cursor (block) */ #define TATTR_PASCURS 0x2UL /* passive cursor (box) */ #define TATTR_RIGHTCURS 0x1UL /* cursor-on-RHS */ #define LATTR_NORM 0x00000000UL #define LATTR_WIDE 0x01000000UL #define LATTR_TOP 0x02000000UL #define LATTR_BOT 0x03000000UL #define LATTR_MODE 0x03000000UL #define LATTR_WRAPPED 0x10000000UL #define ATTR_INVALID 0x00FF0000UL /* Like Linux use the F000 page for direct to font. */ #define ATTR_OEMCP 0x0000F000UL /* OEM Codepage DTF */ #define ATTR_ACP 0x0000F100UL /* Ansi Codepage DTF */ /* These are internal use overlapping with the UTF-16 surrogates */ #define ATTR_ASCII 0x0000D800UL /* normal ASCII charset ESC ( B */ #define ATTR_LINEDRW 0x0000D900UL /* line drawing charset ESC ( 0 */ #define ATTR_SCOACS 0x0000DA00UL /* SCO Alternate charset */ #define ATTR_GBCHR 0x0000DB00UL /* UK variant charset ESC ( A */ #define CSET_MASK 0x0000FF00UL /* Character set mask; MUST be 0xFF00 */ #define DIRECT_CHAR(c) ((c&0xFC00)==0xD800) #define DIRECT_FONT(c) ((c&0xFE00)==0xF000) #define UCSERR (ATTR_LINEDRW|'a') /* UCS Format error character. */ #define UCSWIDE 0x303F #define ATTR_NARROW 0x20000000UL #define ATTR_WIDE 0x10000000UL #define ATTR_BOLD 0x01000000UL #define ATTR_UNDER 0x02000000UL #define ATTR_REVERSE 0x04000000UL #define ATTR_BLINK 0x08000000UL #define ATTR_FGMASK 0x000F0000UL #define ATTR_BGMASK 0x00F00000UL #define ATTR_COLOURS 0x00FF0000UL #define ATTR_FGSHIFT 16 #define ATTR_BGSHIFT 20 #define ATTR_DEFAULT 0x00980000UL #define ATTR_DEFFG 0x00080000UL #define ATTR_DEFBG 0x00900000UL #define ERASE_CHAR (ATTR_DEFAULT | ATTR_ASCII | ' ') #define ATTR_MASK 0xFFFFFF00UL #define CHAR_MASK 0x000000FFUL #define ATTR_CUR_AND (~(ATTR_BOLD|ATTR_REVERSE|ATTR_BLINK|ATTR_COLOURS)) #define ATTR_CUR_XOR 0x00BA0000UL typedef HDC Context; #define SEL_NL { 13, 10 } #define in_utf (utf || line_codepage==CP_UTF8) #define LGXF_OVR 1 /* existing logfile overwrite */ #define LGXF_APN 0 /* existing logfile append */ #define LGXF_ASK -1 /* existing logfile ask */ #define LGTYP_NONE 0 /* logmode: no logging */ #define LGTYP_ASCII 1 /* logmode: pure ascii */ #define LGTYP_DEBUG 2 /* logmode: all chars of traffic */ #define LGTYP_PACKETS 3 /* logmode: SSH data packets */ /* * I've just looked in the windows standard headr files for WM_USER, there * are hundreds of flags defined using the form WM_USER+123 so I've * renumbered this NETEVENT value and the two in window.c */ #define WM_XUSER (WM_USER + 0x2000) #define WM_NETEVENT (WM_XUSER + 5) typedef enum { TS_AYT, TS_BRK, TS_SYNCH, TS_EC, TS_EL, TS_GA, TS_NOP, TS_ABORT, TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF, TS_LECHO, TS_RECHO, TS_PING, TS_EOL } Telnet_Special; typedef enum { MBT_NOTHING, MBT_LEFT, MBT_MIDDLE, MBT_RIGHT, /* `raw' button designations */ MBT_SELECT, MBT_EXTEND, MBT_PASTE, /* `cooked' button designations */ MBT_WHEEL_UP, MBT_WHEEL_DOWN /* mouse wheel */ } Mouse_Button; typedef enum { MA_NOTHING, MA_CLICK, MA_2CLK, MA_3CLK, MA_DRAG, MA_RELEASE } Mouse_Action; typedef enum { VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN, VT_UNICODE } VT_Mode; enum { /* * SSH ciphers (both SSH1 and SSH2) */ CIPHER_WARN, /* pseudo 'cipher' */ CIPHER_3DES, CIPHER_BLOWFISH, CIPHER_AES, /* (SSH 2 only) */ CIPHER_DES, CIPHER_MAX /* no. ciphers (inc warn) */ }; enum { /* * Line discipline option states: off, on, up to the backend. */ LD_YES, LD_NO, LD_BACKEND }; enum { /* * Line discipline options which the backend might try to control. */ LD_EDIT, /* local line editing */ LD_ECHO /* local echo */ }; enum { /* * Close On Exit behaviours. (cfg.close_on_exit) */ COE_NEVER, /* Never close the window */ COE_NORMAL, /* Close window on "normal" (non-error) exits only */ COE_ALWAYS /* Always close the window */ }; /* * You can compile with -DSSH_DEFAULT to have ssh by default. */ #ifndef SSH_DEFAULT #define DEFAULT_PROTOCOL PROT_TELNET #define DEFAULT_PORT 23 #else #define DEFAULT_PROTOCOL PROT_SSH #define DEFAULT_PORT 22 #endif /* * Some global flags denoting the type of application. * * FLAG_VERBOSE is set when the user requests verbose details. * * FLAG_STDERR is set in command-line applications (which have a * functioning stderr that it makes sense to write to) and not in * GUI applications (which don't). * * FLAG_INTERACTIVE is set when a full interactive shell session is * being run, _either_ because no remote command has been provided * _or_ because the application is GUI and can't run non- * interactively. */ #define FLAG_VERBOSE 0x0001 #define FLAG_STDERR 0x0002 #define FLAG_INTERACTIVE 0x0004 GLOBAL int flags; struct RSAKey; /* be a little careful of scope */ void cleanup_exit(int); /* * Exports from noise.c. */ void noise_get_heavy(void (*func) (void *, int)); void noise_get_light(void (*func) (void *, int)); void noise_regular(void); void noise_ultralight(DWORD data); void random_save_seed(void); void random_destroy_seed(void); /* * Exports from rand.c. */ void random_add_noise(void *noise, int length); void random_init(void); int random_byte(void); void random_get_savedata(void **data, int *len); extern int random_active; /* * Exports from misc.c. */ #include "misc.h" /* * Exports from sizetip.c. */ void UpdateSizeTip(HWND src, int cx, int cy); void EnableSizeTip(int bEnable); /* * Exports from mscrypto.c */ #ifdef MSCRYPTOAPI int crypto_startup(); void crypto_wrapup(); #endif --- NEW FILE: INT64.H --- /** * ActiveLock Cryptographic Library * Copyright 2003 The ActiveLock Software Group (ASG) * Portions Copyright by Simon Tatham and the PuTTY project. * * All material is the property of the contributing authors. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * [o] Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * [o] Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * PuTTY License * ============= * * PuTTY is copyright 1997-2001 Simon Tatham. * * Portions copyright Robert de Bath, Joris van Rantwijk, Delian * Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry, * Justin Bradford, and CORE SDI S.A. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation files * (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /* * Header for int64.c. */ #ifndef PUTTY_INT64_H #define PUTTY_INT64_H typedef struct { unsigned long hi, lo; } uint64, int64; uint64 uint64_div10(uint64 x, int *remainder); void uint64_decimal(uint64 x, char *buffer); uint64 uint64_make(unsigned long hi, unsigned long lo); uint64 uint64_add(uint64 x, uint64 y); uint64 uint64_add32(uint64 x, unsigned long y); int uint64_compare(uint64 x, uint64 y); #endif --- NEW FILE: MD5.C --- /** * ActiveLock Cryptographic Library * Copyright 2003 The ActiveLock Software Group (ASG) * Portions Copyright by Simon Tatham and the PuTTY project. * * All material is the property of the contributing authors. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * [o] Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * [o] Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * PuTTY License * ============= * * PuTTY is copyright 1997-2001 Simon Tatham. * * Portions copyright Robert de Bath, Joris van Rantwijk, Delian * Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry, * Justin Bradford, and CORE SDI S.A. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation files * (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #include "crypt.h" /* * MD5 implementation for PuTTY. Written directly from the spec by * Simon Tatham. */ /* ---------------------------------------------------------------------- * Core MD5 algorithm: processes 16-word blocks into a message digest. */ /********************************************************************************************** * Change Log * ========== * * Date (MM/DD/YY) Author Description * --------------- ----------- -------------------------------------------------------------- * 07/27/03 th2tran adapted from PuTTY project for used by ActiveLock project. * ***********************************************************************************************/ #define F(x,y,z) ( ((x) & (y)) | ((~(x)) & (z)) ) #define G(x,y,z) ( ((x) & (z)) | ((~(z)) & (y)) ) #define H(x,y,z) ( (x) ^ (y) ^ (z) ) #define I(x,y,z) ( (y) ^ ( (x) | ~(z) ) ) #define rol(x,y) ( ((x) << (y)) | (((uint32)x) >> (32-y)) ) #define subround(f,w,x,y,z,k,s,ti) \ w = x + rol(w + f(x,y,z) + block[k] + ti, s) void MD5_Core_Init(MD5_Core_State * s) { s->h[0] = 0x67452301; s->h[1] = 0xefcdab89; s->h[2] = 0x98badcfe; s->h[3] = 0x10325476; } void MD5_Block(MD5_Core_State * s, uint32 * block) { uint32 a, b, c, d; a = s->h[0]; b = s->h[1]; c = s->h[2]; d = s->h[3]; subround(F, a, b, c, d, 0, 7, 0xd76aa478); subround(F, d, a, b, c, 1, 12, 0xe8c7b756); subround(F, c, d, a, b, 2, 17, 0x242070db); subround(F, b, c, d, a, 3, 22, 0xc1bdceee); subround(F, a, b, c, d, 4, 7, 0xf57c0faf); subround(F, d, a, b, c, 5, 12, 0x4787c62a); subround(F, c, d, a, b, 6, 17, 0xa8304613); subround(F, b, c, d, a, 7, 22, 0xfd469501); subround(F, a, b, c, d, 8, 7, 0x698098d8); subround(F, d, a, b, c, 9, 12, 0x8b44f7af); subround(F, c, d, a, b, 10, 17, 0xffff5bb1); subround(F, b, c, d, a, 11, 22, 0x895cd7be); subround(F, a, b, c, d, 12, 7, 0x6b901122); subround(F, d, a, b, c, 13, 12, 0xfd987193); subround(F, c, d, a, b, 14, 17, 0xa679438e); subround(F, b, c, d, a, 15, 22, 0x49b40821); subround(G, a, b, c, d, 1, 5, 0xf61e2562); subround(G, d, a, b, c, 6, 9, 0xc040b340); subround(G, c, d, a, b, 11, 14, 0x265e5a51); subround(G, b, c, d, a, 0, 20, 0xe9b6c7aa); subround(G, a, b, c, d, 5, 5, 0xd62f105d); subround(G, d, a, b, c, 10, 9, 0x02441453); subround(G, c, d, a, b, 15, 14, 0xd8a1e681); subround(G, b, c, d, a, 4, 20, 0xe7d3fbc8); subround(G, a, b, c, d, 9, 5, 0x21e1cde6); subround(G, d, a, b, c, 14, 9, 0xc33707d6); subround(G, c, d, a, b, 3, 14, 0xf4d50d87); subround(G, b, c, d, a, 8, 20, 0x455a14ed); subround(G, a, b, c, d, 13, 5, 0xa9e3e905); subround(G, d, a, b, c, 2, 9, 0xfcefa3f8); subround(G, c, d, a, b, 7, 14, 0x676f02d9); subround(G, b, c, d, a, 12, 20, 0x8d2a4c8a); subround(H, a, b, c, d, 5, 4, 0xfffa3942); subround(H, d, a, b, c, 8, 11, 0x8771f681); subround(H, c, d, a, b, 11, 16, 0x6d9d6122); subround(H, b, c, d, a, 14, 23, 0xfde5380c); subround(H, a, b, c, d, 1, 4, 0xa4beea44); subround(H, d, a, b, c, 4, 11, 0x4bdecfa9); subround(H, c, d, a, b, 7, 16, 0xf6bb4b60); subround(H, b, c, d, a, 10, 23, 0xbebfbc70); subround(H, a, b, c, d, 13, 4, 0x289b7ec6); subround(H, d, a, b, c, 0, 11, 0xeaa127fa); subround(H, c, d, a, b, 3, 16, 0xd4ef3085); subround(H, b, c, d, a, 6, 23, 0x04881d05); subround(H, a, b, c, d, 9, 4, 0xd9d4d039); subround(H, d, a, b, c, 12, 11, 0xe6db99e5); subround(H, c, d, a, b, 15, 16, 0x1fa27cf8); subround(H, b, c, d, a, 2, 23, 0xc4ac5665); subround(I, a, b, c, d, 0, 6, 0xf4292244); subround(I, d, a, b, c, 7, 10, 0x432aff97); subround(I, c, d, a, b, 14, 15, 0xab9423a7); subround(I, b, c, d, a, 5, 21, 0xfc93a039); subround(I, a, b, c, d, 12, 6, 0x655b59c3); subround(I, d, a, b, c, 3, 10, 0x8f0ccc92); subround(I, c, d, a, b, 10, 15, 0xffeff47d); subround(I, b, c, d, a, 1, 21, 0x85845dd1); subround(I, a, b, c, d, 8, 6, 0x6fa87e4f); subround(I, d, a, b, c, 15, 10, 0xfe2ce6e0); subround(I, c, d, a, b, 6, 15, 0xa3014314); subround(I, b, c, d, a, 13, 21, 0x4e0811a1); subround(I, a, b, c, d, 4, 6, 0xf7537e82); subround(I, d, a, b, c, 11, 10, 0xbd3af235); subround(I, c, d, a, b, 2, 15, 0x2ad7d2bb); subround(I, b, c, d, a, 9, 21, 0xeb86d391); s->h[0] += a; s->h[1] += b; s->h[2] += c; s->h[3] += d; } /* ---------------------------------------------------------------------- * Outer MD5 algorithm: take an arbitrary length byte string, * convert it into 16-word blocks with the prescribed padding at * the end, and pass those blocks to the core MD5 algorithm. */ #define BLKSIZE 64 void MD5Init(struct MD5Context *s) { MD5_Core_Init(&s->core); s->blkused = 0; s->lenhi = s->lenlo = 0; } void MD5Update(struct MD5Context *s, unsigned char const *p, unsigned len) { unsigned char *q = (unsigned char *) p; uint32 wordblock[16]; uint32 lenw = len; int i; /* * Update the length field. */ s->lenlo += lenw; s->lenhi += (s->lenlo < lenw); if (s->blkused + len < BLKSIZE) { /* * Trivial case: just add to the block. */ memcpy(s->block + s->blkused, q, len); s->blkused += len; } else { /* * We must complete and process at least one block. */ while (s->blkused + len >= BLKSIZE) { memcpy(s->block + s->blkused, q, BLKSIZE - s->blkused); q += BLKSIZE - s->blkused; len -= BLKSIZE - s->blkused; /* Now process the block. Gather bytes little-endian into words */ for (i = 0; i < 16; i++) { wordblock[i] = (((uint32) s->block[i * 4 + 3]) << 24) | (((uint32) s->block[i * 4 + 2]) << 16) | (((uint32) s->block[i * 4 + 1]) << 8) | (((uint32) s->block[i * 4 + 0]) << 0); } MD5_Block(&s->core, wordblock); s->blkused = 0; } memcpy(s->block, q, len); s->blkused = len; } } void MD5Final(unsigned char output[16], struct MD5Context *s) { int i; unsigned pad; unsigned char c[64]; uint32 lenhi, lenlo; if (s->blkused >= 56) pad = 56 + 64 - s->blkused; else pad = 56 - s->blkused; lenhi = (s->lenhi << 3) | (s->lenlo >> (32 - 3)); lenlo = (s->lenlo << 3); memset(c, 0, pad); c[0] = 0x80; MD5Update(s, c, pad); c[7] = (lenhi >> 24) & 0xFF; c[6] = (lenhi >> 16) & 0xFF; c[5] = (lenhi >> 8) & 0xFF; c[4] = (lenhi >> 0) & 0xFF; c[3] = (lenlo >> 24) & 0xFF; c[2] = (lenlo >> 16) & 0xFF; c[1] = (lenlo >> 8) & 0xFF; c[0] = (lenlo >> 0) & 0xFF; MD5Update(s, c, 8); for (i = 0; i < 4; i++) { output[4 * i + 3] = (s->core.h[i] >> 24) & 0xFF; output[4 * i + 2] = (s->core.h[i] >> 16) & 0xFF; output[4 * i + 1] = (s->core.h[i] >> 8) & 0xFF; output[4 * i + 0] = (s->core.h[i] >> 0) & 0xFF; } } /* ---------------------------------------------------------------------- * The above is the MD5 algorithm itself. Now we implement the * HMAC wrapper on it. */ static struct MD5Context md5_cs_mac_s1, md5_cs_mac_s2; static struct MD5Context md5_sc_mac_s1, md5_sc_mac_s2; static void md5_key(struct MD5Context *s1, struct MD5Context *s2, unsigned char *key, int len) { unsigned char foo[64]; int i; memset(foo, 0x36, 64); for (i = 0; i < len && i < 64; i++) foo[i] ^= key[i]; MD5Init(s1); MD5Update(s1, foo, 64); memset(foo, 0x5C, 64); for (i = 0; i < len && i < 64; i++) foo[i] ^= key[i]; MD5Init(s2); MD5Update(s2, foo, 64); memset(foo, 0, 64); /* burn the evidence */ } static void md5_cskey(unsigned char *key) { md5_key(&md5_cs_mac_s1, &md5_cs_mac_s2, key, 16); } static void md5_sckey(unsigned char *key) { md5_key(&md5_sc_mac_s1, &md5_sc_mac_s2, key, 16); } static void md5_do_hmac(struct MD5Context *s1, struct MD5Context *s2, unsigned char *blk, int len, unsigned long seq, unsigned char *hmac) { struct MD5Context s; unsigned char intermediate[16]; intermediate[0] = (unsigned char) ((seq >> 24) & 0xFF); intermediate[1] = (unsigned char) ((seq >> 16) & 0xFF); intermediate[2] = (unsigned char) ((seq >> 8) & 0xFF); intermediate[3] = (unsigned char) ((seq) & 0xFF); s = *s1; /* structure copy */ MD5Update(&s, intermediate, 4); MD5Update(&s, blk, len); MD5Final(intermediate, &s); s = *s2; /* structure copy */ MD5Update(&s, intermediate, 16); MD5Final(hmac, &s); } static void md5_generate(unsigned char *blk, int len, unsigned long seq) { md5_do_hmac(&md5_cs_mac_s1, &md5_cs_mac_s2, blk, len, seq, blk + len); } static int md5_verify(unsigned char *blk, int len, unsigned long seq) { unsigned char correct[16]; md5_do_hmac(&md5_sc_mac_s1, &md5_sc_mac_s2, blk, len, seq, correct); return !memcmp(correct, blk + len, 16); } const struct ssh_mac ssh_md5 = { md5_cskey, md5_sckey, md5_generate, md5_verify, "hmac-md5", 16 }; --- NEW FILE: MISC.C --- /** * ActiveLock Cryptographic Library * Copyright 2003 The ActiveLock Software Group (ASG) * Portions Copyright by Simon Tatham and the PuTTY project. * * All material is the property of the contributing authors. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * [o] Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * [o] Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * PuTTY License * ============= * * PuTTY is copyright 1997-2001 Simon Tatham. * * Portions copyright Robert de Bath, Joris van Rantwijk, Delian * Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry, * Justin Bradford, and CORE SDI S.A. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation files * (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /** * Miscellaneous utility functions. */ /********************************************************************************************** * Change Log * ========== * * Date (MM/DD/YY) Author Description * --------------- ----------- -------------------------------------------------------------- * 07/27/03 th2tran adapted from PuTTY project for used by ActiveLock project. * ***********************************************************************************************/ #include <windows.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> #include "crypt.h" static char seedpath[2 * MAX_PATH + 10] = "\0"; static char hex[16] = "0123456789ABCDEF"; void cleanup_exit(int code) { exit(code); } /* ---------------------------------------------------------------------- * String handling routines. */ char *dupstr(char *s) { int len = strlen(s); char *p = smalloc(len + 1); strcpy(p, s); return p; } /* Allocate the concatenation of N strings. Terminate arg list with NULL. */ char *dupcat(char *s1, ...) { int len; char *p, *q, *sn; va_list ap; len = strlen(s1); va_start(ap, s1); while (1) { sn = va_arg(ap, char *); if (!sn) break; len += strlen(sn); } va_end(ap); p = smalloc(len + 1); strcpy(p, s1); q = p + strlen(p); va_start(ap, s1); while (1) { sn = va_arg(ap, char *); if (!sn) break; strcpy(q, sn); q += strlen(q); } va_end(ap); return p; } /* ---------------------------------------------------------------------- * Base64 encoding routine. This is required in public-key writing * but also in HTTP proxy handling, so it's centralised here. */ void base64_encode_atom(unsigned char *data, int n, char *out) { static const char base64_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; unsigned word; word = data[0] << 16; if (n > 1) word |= data[1] << 8; if (n > 2) word |= data[2]; out[0] = base64_chars[(word >> 18) & 0x3F]; out[1] = base64_chars[(word >> 12) & 0x3F]; if (n > 1) out[2] = base64_chars[(word >> 6) & 0x3F]; else out[2] = '='; if (n > 2) out[3] = base64_chars[word & 0x3F]; else out[3] = '='; } int base64_decode_atom(char *atom, unsigned char *out) { int vals[4]; int i, v, len; unsigned word; char c; for (i = 0; i < 4; i++) { c = atom[i]; if (c >= 'A' && c <= 'Z') v = c - 'A'; else if (c >= 'a' && c <= 'z') v = c - 'a' + 26; else if (c >= '0' && c <= '9') v = c - '0' + 52; else if (c == '+') v = 62; else if (c == '/') v = 63; else if (c == '=') v = -1; else return 0; /* invalid atom */ vals[i] = v; } if (vals[0] == -1 || vals[1] == -1) return 0; if (vals[2] == -1 && vals[3] != -1) return 0; if (vals[3] != -1) len = 3; else if (vals[2] != -1) len = 2; else len = 1; word = ((vals[0] << 18) | (vals[1] << 12) | ((vals[2] & 0x3F) << 6) | (vals[3] & 0x3F)); out[0] = (word >> 16) & 0xFF; if (len > 1) out[1] = (word >> 8) & 0xFF; if (len > 2) out[2] = word & 0xFF; return len; } /* ---------------------------------------------------------------------- * Generic routines to deal with send buffers: a linked list of * smallish blocks, with the operations * * - add an arbitrary amount of data to the end of the list * - remove the first N bytes from the list * - return a (pointer,length) pair giving some initial data in * the list, suitable for passing to a send or write system * call * - retrieve a larger amount of initial data from the list * - return the current size of the buffer chain in bytes */ #define BUFFER_GRANULE 512 struct bufchain_granule { struct bufchain_granule *next; int buflen, bufpos; char buf[BUFFER_GRANULE]; }; void bufchain_init(bufchain *ch) { ch->head = ch->tail = NULL; ch->buffersize = 0; } void bufchain_clear(bufchain *ch) { struct bufchain_granule *b; while (ch->head) { b = ch->head; ch->head = ch->head->next; sfree(b); } ch->tail = NULL; ch->buffersize = 0; } int bufchain_size(bufchain *ch) { return ch->buffersize; } void bufchain_add(bufchain *ch, void *data, int len) { char *buf = (char *)data; ch->buffersize += len; if (ch->tail && ch->tail->buflen < BUFFER_GRANULE) { int copylen = min(len, BUFFER_GRANULE - ch->tail->buflen); memcpy(ch->tail->buf + ch->tail->buflen, buf, copylen); buf += copylen; len -= copylen; ch->tail->buflen += copylen; } while (len > 0) { int grainlen = min(len, BUFFER_GRANULE); struct bufchain_granule *newbuf; newbuf = smalloc(sizeof(struct bufchain_granule)); newbuf->bufpos = 0; newbuf->buflen = grainlen; memcpy(newbuf->buf, buf, grainlen); buf += grainlen; len -= grainlen; if (ch->tail) ch->tail->next = newbuf; else ch->head = ch->tail = newbuf; newbuf->next = NULL; ch->tail = newbuf; } } void bufchain_consume(bufchain *ch, int len) { struct bufchain_granule *tmp; assert(ch->buffersize >= len); while (len > 0) { int remlen = len; assert(ch->head != NULL); if (remlen >= ch->head->buflen - ch->head->bufpos) { remlen = ch->head->buflen - ch->head->bufpos; tmp = ch->head; ch->head = tmp->next; sfree(tmp); if (!ch->head) ch->tail = NULL; } else ch->head->bufpos += remlen; ch->buffersize -= remlen; len -= remlen; } } void bufchain_prefix(bufchain *ch, void **data, int *len) { *len = ch->head->buflen - ch->head->bufpos; *data = ch->head->buf + ch->head->bufpos; } void bufchain_fetch(bufchain *ch, void *data, int len) { struct bufchain_granule *tmp; char *data_c = (char *)data; tmp = ch->head; assert(ch->buffersize >= len); while (len > 0) { int remlen = len; assert(tmp != NULL); if (remlen >= tmp->buflen - tmp->bufpos) remlen = tmp->buflen - tmp->bufpos; memcpy(data_c, tmp->buf + tmp->bufpos, remlen); tmp = tmp->next; len -= remlen; data_c += remlen; } } /* ---------------------------------------------------------------------- * My own versions of malloc, realloc and free. Because I want * malloc and realloc to bomb out and exit the program if they run * out of memory, realloc to reliably call malloc if passed a NULL * pointer, and free to reliably do nothing if passed a NULL * pointer. We can also put trace printouts in, if we need to; and * we can also replace the allocator with an ElectricFence-like * one. */ #ifdef MINEFIELD /* * Minefield - a Windows equivalent for Electric Fence */ #define PAGESIZE 4096 /* * Design: * * We start by reserving as much virtual address space as Windows * will sensibly (or not sensibly) let us have. We flag it all as * invalid memory. * * Any allocation attempt is satisfied by committing one or more * pages, with an uncommitted page on either side. The returned * memory region is jammed up against the _end_ of the pages. * * Freeing anything causes instantaneous decommitment of the pages * involved, so stale pointers are caught as soon as possible. */ static int minefield_initialised = 0; static void *minefield_region = NULL; static long minefield_size = 0; static long minefield_npages = 0; static long minefield_curpos = 0; static unsigned short *minefield_admin = NULL; static void *minefield_pages = NULL; static void minefield_admin_hide(int hide) { int access = hide ? PAGE_NOACCESS : PAGE_READWRITE; VirtualProtect(minefield_admin, minefield_npages * 2, access, NULL); } static void minefield_init(void) { int size; int admin_size; int i; for (size = 0x40000000; size > 0; size = ((size >> 3) * 7) & ~0xFFF) { minefield_region = VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS); if (minefield_region) break; } minefield_size = size; /* * Firstly, allocate a section of that to be the admin block. * We'll need a two-byte field for each page. */ minefield_admin = minefield_region; minefield_npages = minefield_size / PAGESIZE; admin_size = (minefield_npages * 2 + PAGESIZE - 1) & ~(PAGESIZE - 1); minefield_npages = (minefield_size - admin_size) / PAGESIZE; minefield_pages = (char *) minefield_region + admin_size; /* * Commit the admin region. */ VirtualAlloc(minefield_admin, minefield_npages * 2, MEM_COMMIT, PAGE_READWRITE); /* * Mark all pages as unused (0xFFFF). */ for (i = 0; i < minefield_npages; i++) minefield_admin[i] = 0xFFFF; /* * Hide the admin region. */ minefield_admin_hide(1); minefield_initialised = 1; } static void minefield_bomb(void) { div(1, *(int *) minefield_pages); } static void *minefield_alloc(int size) { int npages; int pos, lim, region_end, region_start; int start; int i; npages = (size + PAGESIZE - 1) / PAGESIZE; minefield_admin_hide(0); /* * Search from current position until we find a contiguous * bunch of npages+2 unused pages. */ pos = minefield_curpos; lim = minefield_npages; while (1) { /* Skip over used pages. */ while (pos < lim && minefield_admin[pos] != 0xFFFF) pos++; /* Count unused pages. */ start = pos; while (pos < lim && pos - start < npages + 2 && minefield_admin[pos] == 0xFFFF) pos++; if (pos - start == npages + 2) break; /* If we've reached the limit, reset the limit or stop. */ if (pos >= lim) { if (lim == minefield_npages) { /* go round and start again at zero */ lim = minefield_curpos; pos = 0; } else { minefield_admin_hide(1); return NULL; } } } minefield_curpos = pos - 1; /* * We have npages+2 unused pages starting at start. We leave * the first and last of these alone and use the rest. */ region_end = (start + npages + 1) * PAGESIZE; region_start = region_end - size; /* FIXME: could align here if we wanted */ /* * Update the admin region. */ for (i = start + 2; i < start + npages + 1; i++) minefield_admin[i] = 0xFFFE; /* used but no region starts here */ minefield_admin[start + 1] = region_start % PAGESIZE; minefield_admin_hide(1); VirtualAlloc((char *) minefield_pages + region_start, size, MEM_COMMIT, PAGE_READWRITE); return (char *) minefield_pages + region_start; } static void minefield_free(void *ptr) { int region_start, i, j; minefield_admin_hide(0); region_start = (char *) ptr - (char *) minefield_pages; i = region_start / PAGESIZE; if (i < 0 || i >= minefield_npages || minefield_admin[i] != region_start % PAGESIZE) minefield_bomb(); for (j = i; j < minefield_npages && minefield_admin[j] != 0xFFFF; j++) { minefield_admin[j] = 0xFFFF; } VirtualFree(ptr, j * PAGESIZE - region_start, MEM_DECOMMIT); minefield_admin_hide(1); } static int minefield_get_size(void *ptr) { int region_start, i, j; minefield_admin_hide(0); region_start = (char *) ptr - (char *) minefield_pages; i = region_start / PAGESIZE; if (i < 0 || i >= minefield_npages || minefield_admin[i] != region_start % PAGESIZE) minefield_bomb(); for (j = i; j < minefield_npages && minefield_admin[j] != 0xFFFF; j++); minefield_admin_hide(1); return j * PAGESIZE - region_start; } static void *minefield_c_malloc(size_t size) { if (!minefield_initialised) minefield_init(); return minefield_alloc(size); } static void minefield_c_free(void *p) { if (!minefield_initialised) minefield_init(); minefield_free(p); } /* * realloc _always_ moves the chunk, for rapid detection of code * that assumes it won't. */ static void *minefield_c_realloc(void *p, size_t size) { size_t oldsize; void *q; if (!minefield_initialised) minefield_init(); q = minefield_alloc(size); oldsize = minefield_get_size(p); memcpy(q, p, (oldsize < size ? oldsize : size)); minefield_free(p); return q; } #endif /* MINEFIELD */ #ifdef MALLOC_LOG static FILE *fp = NULL; static char *mlog_file = NULL; static int mlog_line = 0; void mlog(char *file, int line) { mlog_file = file; mlog_line = line; if (!fp) { fp = fopen("alcrypto_mem.log", "w"); setvbuf(fp, NULL, _IONBF, BUFSIZ); } if (fp) fprintf(fp, "%s:%d: ", file, line); } #endif void *safemalloc(size_t size) { void *p; #ifdef MINEFIELD p = minefield_c_malloc(size); #else p = malloc(size); #endif if (!p) { char str[200]; #ifdef MALLOC_LOG sprintf(str, "Out of memory! (%s:%d, size=%d)", mlog_file, mlog_line, size); fprintf(fp, "*** %s\n", str); fclose(fp); #else strcpy(str, "Out of memory!"); #endif MessageBox(NULL, str, "ALCrypto Fatal Error", MB_SYSTEMMODAL | MB_ICONERROR | MB_OK); cleanup_exit(1); } #ifdef MALLOC_LOG if (fp) fprintf(fp, "malloc(%d) returns %p\n", size, p); #endif return p; } void *saferealloc(void *ptr, size_t size) { void *p; if (!ptr) { #ifdef MINEFIELD p = minefield_c_malloc(size); #else p = malloc(size); #endif } else { #ifdef MINEFIELD p = minefield_c_realloc(ptr, size); #else p = realloc(ptr, size); #endif } if (!p) { char str[200]; #ifdef MALLOC_LOG sprintf(str, "Out of memory! (%s:%d, size=%d)", mlog_file, mlog_line, size); fprintf(fp, "*** %s\n", str); fclose(fp); #else strcpy(str, "Out of memory!"); #endif MessageBox(NULL, str, "ALCrypto Fatal Error", MB_SYSTEMMODAL | MB_ICONERROR | MB_OK); cleanup_exit(1); } #ifdef MALLOC_LOG if (fp) fprintf(fp, "realloc(%p,%d) returns %p\n", ptr, size, p); #endif return p; } void safefree(void *ptr) { if (ptr) { #ifdef MALLOC_LOG if (fp) fprintf(fp, "free(%p)\n", ptr); #endif #ifdef MINEFIELD minefield_c_free(ptr); #else free(ptr); #endif } #ifdef MALLOC_LOG else if (fp) fprintf(fp, "freeing null pointer - no action taken\n"); #endif } /* ---------------------------------------------------------------------- * Debugging routines. */ #ifdef _DEBUG static FILE *debug_fp = NULL; static int debug_got_console = 0; static void dputs(char *buf) { DWORD dw; if (!debug_got_console) { AllocConsole(); debug_got_console = 1; } if (!debug_fp) { debug_fp = fopen("debug.log", "w"); } WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), buf, strlen(buf), &dw, NULL); fputs(buf, debug_fp); fflush(debug_fp); } void dprintf(char *fmt, ...) { char buf[2048]; va_list ap; va_start(ap, fmt); vsprintf(buf, fmt, ap); dputs(buf); va_end(ap); } void debug_memdump(void *buf, int len, int L) { int i; unsigned char *p = buf; char foo[17]; if (L) { int delta; dprintf("\t%d (0x%x) bytes:\n", len, len); delta = 15 & (int) p; p -= delta; len += delta; } for (; 0 < len; p += 16, len -= 16) { dputs(" "); if (L) dprintf("%p: ", p); strcpy(foo, "................"); /* sixteen dots */ for (i = 0; i < 16 && i < len; ++i) { if (&p[i] < (unsigned char *) buf) { dputs(" "); /* 3 spaces */ foo[i] = ' '; } else { dprintf("%c%02.2x", &p[i] != (unsigned char *) buf && i % 4 ? '.' : ' ', p[i] ); if (p[i] >= ' ' && p[i] <= '~') foo[i] = (char) p[i]; } } foo[i] = '\0'; dprintf("%*s%s\n", (16 - i) * 3 + 2, "", foo); } } #endif /* def DEBUG */ /* * Find the random seed file path and store it in `seedpath'. */ static void get_seedpath(void) { HKEY rkey; DWORD type, size; size = sizeof(seedpath); if (RegOpenKey(HKEY_CURRENT_USER, REG_HOME, &rkey) == ERROR_SUCCESS) { i... [truncated message content] |
From: Thanh H. T. <th...@us...> - 2003-07-28 00:58:04
|
Update of /cvsroot/activelock/alcrypto In directory sc8-pr-cvs1:/tmp/cvs-serv27519/alcrypto Log Message: Directory /cvsroot/activelock/alcrypto added to the repository |
From: Thanh H. T. <th...@us...> - 2003-07-23 07:04:11
|
Update of /cvsroot/activelock/activelock2/src In directory sc8-pr-cvs1:/tmp/cvs-serv6276 Modified Files: Globals.cls Log Message: Was getting the error "Variable uses an Automation type not supported by Visual Basic" when trying to make ActiveLock2.dll. Index: Globals.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/Globals.cls,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Globals.cls 23 Jul 2003 03:55:21 -0000 1.5 +++ Globals.cls 23 Jul 2003 07:04:08 -0000 1.6 @@ -98,7 +98,7 @@ '' ' Returns a new instance of an object that implements IActiveLock interface. ' -Public Function NewInstance(Optional Args As Variant = Empty) As IActiveLock 'TODO: Add parameters as appropriate +Public Function NewInstance(Optional Args As Variant) As IActiveLock 'TODO: Add parameters as appropriate Dim NewInst As IActiveLock Set NewInst = New ActiveLock With NewInst |
From: Thanh H. T. <th...@us...> - 2003-07-23 06:41:29
|
Update of /cvsroot/activelock/activelock2/src In directory sc8-pr-cvs1:/tmp/cvs-serv3736 Modified Files: ActiveLockEventNotifier.cls Log Message: Reduced scope of Notify() Index: ActiveLockEventNotifier.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ActiveLockEventNotifier.cls,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ActiveLockEventNotifier.cls 21 Jul 2003 08:48:27 -0000 1.1 +++ ActiveLockEventNotifier.cls 23 Jul 2003 06:41:26 -0000 1.2 @@ -85,7 +85,7 @@ ' @param Result Encrypted value. Public Event ValidateValue(ByVal Value As String, Result As String) -Public Sub Notify(EventName As String, ParamArray Args()) +Friend Sub Notify(EventName As String, ParamArray Args()) If EventName = "ValidateKey" Then RaiseEvent ValidateKey(CStr(Args(0)), CStr(Args(1)), Args(2)) ElseIf EventName = "ValidateValue" Then |
From: Thanh H. T. <th...@us...> - 2003-07-23 03:55:24
|
Update of /cvsroot/activelock/activelock2/src In directory sc8-pr-cvs1:/tmp/cvs-serv12533 Modified Files: FileKeyStore.cls Globals.cls IKeyStoreProvider.cls Log Message: Added some TODO items. Index: FileKeyStore.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/FileKeyStore.cls,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FileKeyStore.cls 21 Jul 2003 08:48:27 -0000 1.4 +++ FileKeyStore.cls 23 Jul 2003 03:55:21 -0000 1.5 @@ -53,7 +53,7 @@ ' / MODULE TO DO LIST / ' /////////////////////////////////////////////////////////////////////// ' -' [ ] Implement IKeyStoreProvider_Store subroutine +' [ ] IKeyStoreProvider_Store() - need to handle file locking for concurrent licensing. ' ' ' /////////////////////////////////////////////////////////////////////// Index: Globals.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/Globals.cls,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Globals.cls 21 Jul 2003 08:48:27 -0000 1.4 +++ Globals.cls 23 Jul 2003 03:55:21 -0000 1.5 @@ -53,9 +53,8 @@ ' / MODULE TO DO LIST / ' /////////////////////////////////////////////////////////////////////// ' -' [ ] Add parameters to NewInstance -' [ ] Initialize proteries in NewInstance -' +' [ ] GetClassString() - handle the rest of the LockTypes +' [ ] GetLicTypeString() - implement this ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CHANGE LOG / @@ -63,13 +62,11 @@ ' ' 07.07.03 - mcrute - Updated the header comments for this file. ' 07.21.03 - th2tran - Added ActiveLockErrCodeConstants to contain -' a list of error code constants for ActiveLock. +' a list of error code constants raised by ActiveLock. ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// - - Option Explicit '' @@ -114,7 +111,7 @@ '' ' Instantiates a new ProductLicense object. ' -Public Function CreateProductLicense(Name As String, _ +Public Function CreateProductLicense(name As String, _ Code As String, _ Ver As String, _ LicClass As ActiveLock2.ALLockTypes, _ @@ -127,7 +124,7 @@ ) As ProductLicense Dim NewLic As New ProductLicense With NewLic - .ProductName = Name + .ProductName = name .ProductKey = Code .ProductVer = Ver .LicenseClass = GetClassString(LicClass) @@ -151,6 +148,9 @@ End If End Function +'' +' Returns a string version of LicType +' Private Function GetLicTypeString(LicType As ALLicType) As String 'TODO: Implement this properly. GetLicTypeString = "Single" Index: IKeyStoreProvider.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/IKeyStoreProvider.cls,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- IKeyStoreProvider.cls 21 Jul 2003 08:48:27 -0000 1.4 +++ IKeyStoreProvider.cls 23 Jul 2003 03:55:21 -0000 1.5 @@ -73,7 +73,8 @@ '' -' Specifies the path under which store keys +' Specifies the path under which the keys are stored. +' Example: path to a license file, or path to the Windows Registry hive. ' Public Property Let KeyStorePath(Path As String) @@ -87,7 +88,7 @@ End Function '' -' Stores a license +' Stores a license. ' Public Sub Store(Lic As ProductLicense) |
From: Thanh H. T. <th...@us...> - 2003-07-23 03:53:46
|
Update of /cvsroot/activelock/activelock2/src In directory sc8-pr-cvs1:/tmp/cvs-serv12306 Modified Files: ActiveLock.cls IActiveLock.cls Log Message: Added IActiveLock_GetLockString() interface Index: ActiveLock.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ActiveLock.cls,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ActiveLock.cls 21 Jul 2003 08:48:27 -0000 1.4 +++ ActiveLock.cls 23 Jul 2003 03:53:43 -0000 1.5 @@ -55,9 +55,10 @@ ' / MODULE TO DO LIST / ' /////////////////////////////////////////////////////////////////////// ' -' [ ] Finish implementing IActiveLock_Acquire +' [ ] Implement IActiveLock_GetLockString() for locktypes other than MAC +' [ ] IActiveLock_Acquire: Check if license has not expired ' [ ] Implement IActiveLock_Release -' [ [ Implement IActiveLock_Transfer +' [ ] Implement IActiveLock_Transfer ' /////////////////////////////////////////////////////////////////////// ' / MODULE CHANGE LOG / ' /////////////////////////////////////////////////////////////////////// @@ -96,6 +97,28 @@ Set IActiveLock_EventNotifier = MyNotifier End Property +Private Function IActiveLock_GetLockString(Optional Lic As ProductLicense = Nothing) As String + Dim strLock As String + + If (mLockTypes And lockMAC) = lockMAC Then + strLock = strLock & modMACAddress.GetMACAddress() + End If + If mLockTypes And lockComp Then + ' TODO: strLock = strLock & GetComputerName() + End If + If mLockTypes And lockHD Then + ' TODO: strLock = strLock & GetComputerName() + End If + If mLockTypes And lockWindows Then + ' TODO: strLock = strLock & GetWindowSerial() + End If + If Lic Is Nothing Then + IActiveLock_GetLockString = strLock + Else + IActiveLock_GetLockString = Lic.ToString() & vbCrLf & strLock + End If +End Function + Private Sub IActiveLock_Init(Arg1 As Variant, ParamArray OtherArgs() As Variant) ' Do nothing. No extra initialization needed for now. End Sub @@ -111,30 +134,23 @@ Err.Raise ActiveLockErrCodeConstants.alerrNoLicense, "IActiveLock_Acquire", "No valid license" End If Dim varResult As Variant - MyNotifier.Notify "ValidateKey", GetLockString(Lic), Lic.LicenseKey, varResult + MyNotifier.Notify "ValidateKey", IActiveLock_GetLockString(Lic), Lic.LicenseKey, varResult ' Check varResult for an affirmative If CLng(varResult) <> modActiveLock.MAGICNUMBER_YES Then Err.Raise ActiveLockErrCodeConstants.alerrLicenseInvalid, "IActiveLock_RegisteredDate", "License invalid." End If + ' TODO: Check if license has not expired End Sub -'' -' Retrieves the lock string from the specified license -Private Function GetLockString(Lic As ProductLicense) As String - Dim strLic As String - strLic = Lic.ToString() & vbLf & modMACAddress.GetMACAddress() ' LOCK TO MAC - GetLockString = strLic -End Function - Private Property Get IActiveLock_RegisteredDate() As String Dim Lic As ProductLicense - Set Lic = mKeyStore.Retrieve(mSoftwareCode) + Set Lic = mKeyStore.Retrieve(mSoftwareName) If Lic Is Nothing Then Err.Raise ActiveLockErrCodeConstants.alerrNoLicense, "IActiveLock_RegisteredDate", "No license." End If ' Validate the License. Dim varResult As Variant - MyNotifier.Notify "ValidateKey", GetLockString(Lic), Lic.LicenseKey, varResult + MyNotifier.Notify "ValidateKey", IActiveLock_GetLockString(Lic), Lic.LicenseKey, varResult If CLng(varResult) <> modActiveLock.MAGICNUMBER_YES Then Err.Raise ActiveLockErrCodeConstants.alerrLicenseInvalid, "IActiveLock_RegisteredDate", "License invalid." End If @@ -185,7 +201,7 @@ ' - registered user ' - expiry date Dim varResult As Variant - MyNotifier.Notify "ValidateKey", GetLockString(Lic), Lic.LicenseKey, varResult + MyNotifier.Notify "ValidateKey", IActiveLock_GetLockString(Lic), Lic.LicenseKey, varResult If CLng(varResult) <> modActiveLock.MAGICNUMBER_YES Then Err.Raise ActiveLockErrCodeConstants.alerrLicenseInvalid, "IActiveLock_Register", "License invalid." End If Index: IActiveLock.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/IActiveLock.cls,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- IActiveLock.cls 21 Jul 2003 08:48:27 -0000 1.4 +++ IActiveLock.cls 23 Jul 2003 03:53:43 -0000 1.5 @@ -202,6 +202,15 @@ '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '' +' Returns the lock string corresponding to the set LockType. +' Optionally, if a product license is specified, then a lock string specific to that license is returned. +' +Public Function GetLockString(Optional Lic As ProductLicense = Nothing) As String + +End Function + + +'' ' Registers the following product license. ' Public Sub Register(Lic As ProductLicense) |
From: Thanh H. T. <th...@us...> - 2003-07-23 03:50:33
|
Update of /cvsroot/activelock/activelock2/test In directory sc8-pr-cvs1:/tmp/cvs-serv11986 Modified Files: frmMain.frm Log Message: - Fixed bug: was Register button was using the wrong text field for liberation key - enabled/disabled the 3rd tab appropriate based on validity of license Index: frmMain.frm =================================================================== RCS file: /cvsroot/activelock/activelock2/test/frmMain.frm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- frmMain.frm 21 Jul 2003 08:54:38 -0000 1.2 +++ frmMain.frm 23 Jul 2003 03:50:26 -0000 1.3 @@ -22,48 +22,35 @@ _ExtentX = 13996 _ExtentY = 11033 _Version = 393216 + Tab = 1 TabHeight = 520 TabCaption(0) = "Admin" TabPicture(0) = "frmMain.frx":0000 - Tab(0).ControlEnabled= -1 'True + Tab(0).ControlEnabled= 0 'False Tab(0).Control(0)= "Label1" - Tab(0).Control(0).Enabled= 0 'False Tab(0).Control(1)= "Label2" - Tab(0).Control(1).Enabled= 0 'False Tab(0).Control(2)= "Label3" - Tab(0).Control(2).Enabled= 0 'False Tab(0).Control(3)= "Label9" - Tab(0).Control(3).Enabled= 0 'False Tab(0).Control(4)= "Label10" - Tab(0).Control(4).Enabled= 0 'False Tab(0).Control(5)= "lblExpiry" - Tab(0).Control(5).Enabled= 0 'False Tab(0).Control(6)= "lblDays" - Tab(0).Control(6).Enabled= 0 'False Tab(0).Control(7)= "cmdSoftwareCodeGen" - Tab(0).Control(7).Enabled= 0 'False Tab(0).Control(8)= "cmbLicClass" - Tab(0).Control(8).Enabled= 0 'False Tab(0).Control(9)= "txtName" - Tab(0).Control(9).Enabled= 0 'False Tab(0).Control(10)= "txtVersion" - Tab(0).Control(10).Enabled= 0 'False Tab(0).Control(11)= "txtSoftwareCodePriv" - Tab(0).Control(11).Enabled= 0 'False Tab(0).Control(12)= "txtSoftwareCodePub" - Tab(0).Control(12).Enabled= 0 'False Tab(0).Control(13)= "cmbLicType" - Tab(0).Control(13).Enabled= 0 'False Tab(0).Control(14)= "txtDays" - Tab(0).Control(14).Enabled= 0 'False Tab(0).Control(15)= "fraKeyGen" - Tab(0).Control(15).Enabled= 0 'False Tab(0).ControlCount= 16 TabCaption(1) = "Registration" TabPicture(1) = "frmMain.frx":001C - Tab(1).ControlEnabled= 0 'False + Tab(1).ControlEnabled= -1 'True Tab(1).Control(0)= "fraReg" + Tab(1).Control(0).Enabled= 0 'False Tab(1).Control(1)= "fraRegStatus" + Tab(1).Control(1).Enabled= 0 'False Tab(1).ControlCount= 2 TabCaption(2) = "Test Functionality" TabPicture(2) = "frmMain.frx":0038 @@ -75,7 +62,7 @@ Begin VB.Frame fraKeyGen Caption = "Key Generator" Height = 2415 - Left = 120 + Left = -74880 TabIndex = 43 Top = 2760 Width = 7455 @@ -122,7 +109,7 @@ Begin VB.TextBox txtDays BackColor = &H80000011& Height = 285 - Left = 1320 + Left = -73680 Locked = -1 'True TabIndex = 40 Text = "30" @@ -132,7 +119,7 @@ Begin VB.ComboBox cmbLicType Height = 315 ItemData = "frmMain.frx":0054 - Left = 1320 + Left = -73680 List = "frmMain.frx":0061 Style = 2 'Dropdown List TabIndex = 3 @@ -142,7 +129,7 @@ Begin VB.TextBox txtSoftwareCodePub BackColor = &H80000011& Height = 285 - Left = 3840 + Left = -71160 Locked = -1 'True TabIndex = 34 Top = 960 @@ -151,7 +138,7 @@ Begin VB.TextBox txtSoftwareCodePriv BackColor = &H80000011& Height = 285 - Left = 1320 + Left = -73680 Locked = -1 'True TabIndex = 35 Top = 960 @@ -160,7 +147,7 @@ Begin VB.TextBox txtVersion BackColor = &H80000011& Height = 285 - Left = 1320 + Left = -73680 Locked = -1 'True TabIndex = 38 Top = 720 @@ -169,7 +156,7 @@ Begin VB.TextBox txtName BackColor = &H80000011& Height = 285 - Left = 1320 + Left = -73680 Locked = -1 'True TabIndex = 36 Top = 480 @@ -297,7 +284,7 @@ TickerFontSize = 11.25 TickerFlash = 0 'False TickerPlaySound = 0 'False - TickerScrollX = 168 + TickerScrollX = 321 BalloonTipIcon = 0 BalloonTipText = "No Messages" End @@ -331,7 +318,7 @@ Begin VB.Frame fraRegStatus Caption = "Status" Height = 2655 - Left = -74880 + Left = 120 TabIndex = 11 Top = 480 Width = 7695 @@ -390,7 +377,7 @@ Begin VB.Frame fraReg Caption = "Register" Height = 2895 - Left = -74880 + Left = 120 TabIndex = 7 Top = 3240 Width = 7695 @@ -462,7 +449,7 @@ Begin VB.ComboBox cmbLicClass Height = 315 ItemData = "frmMain.frx":0136 - Left = 1320 + Left = -73680 List = "frmMain.frx":0140 Style = 2 'Dropdown List TabIndex = 4 @@ -473,7 +460,7 @@ Caption = "&Generate" Enabled = 0 'False Height = 255 - Left = 6480 + Left = -68520 TabIndex = 2 Top = 960 Width = 1215 @@ -481,7 +468,7 @@ Begin VB.Label lblDays Caption = "days" Height = 255 - Left = 2640 + Left = -72360 TabIndex = 42 Top = 1890 Width = 1335 @@ -489,7 +476,7 @@ Begin VB.Label lblExpiry Caption = "Expires after:" Height = 255 - Left = 120 + Left = -74880 TabIndex = 41 Top = 1850 Width = 1335 @@ -497,7 +484,7 @@ Begin VB.Label Label10 Caption = " Version:" Height = 255 - Left = 120 + Left = -74880 TabIndex = 39 Top = 720 Width = 1335 @@ -505,7 +492,7 @@ Begin VB.Label Label9 Caption = "Software Name:" Height = 255 - Left = 120 + Left = -74880 TabIndex = 37 Top = 480 Width = 1335 @@ -513,7 +500,7 @@ Begin VB.Label Label3 Caption = "License Class:" Height = 255 - Left = 120 + Left = -74880 TabIndex = 6 Top = 2130 Width = 1335 @@ -521,7 +508,7 @@ Begin VB.Label Label2 Caption = "License Type:" Height = 255 - Left = 120 + Left = -74880 TabIndex = 5 Top = 1560 Width = 1335 @@ -529,7 +516,7 @@ Begin VB.Label Label1 Caption = " Code:" Height = 255 - Left = 120 + Left = -74880 TabIndex = 1 Top = 960 Width = 1335 @@ -575,7 +562,7 @@ '' ' This test app is used to exercise all functionalities of ActiveLock. ' -' @author th...@us... +' @author th2tran ' @version 2.0.0 ' @date 20030715 @@ -583,8 +570,10 @@ ' / MODULE TO DO LIST / ' /////////////////////////////////////////////////////////////////////// ' -' [ ] Add some TODO items here -' +' [ ] Re: GetMACAndUserFromRequestCode(), try to move the decoding of the +' request code inside ActiveLock. We need to abstract this, if possible, +' such that the client app doesn't need to understand how the request +' code was encoded. ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CHANGE LOG / @@ -721,7 +710,7 @@ Set Lic = ActiveLock2.CreateProductLicense(txtName, txtSoftwareCodePub, _ txtVersion, MyActiveLock.LockType, MyActiveLock.LicenseType, strUser, strExpire) Dim strLic As String * 2048 - strLic = Lic.ToString() & vbLf & strMAC + strLic = MyActiveLock.GetLockString(Lic) ' encrypt using public key so that only us can decrypt it later strLic = modMain.Encrypt(strLic) txtLibKey = strLic @@ -747,7 +736,7 @@ Private Function IndexOf(Str As String, char As Byte) As Integer IndexOf = -1 - On Error GoTo ErrHandler + On Error GoTo errHandler Dim arrBytes() As Byte arrBytes = StrConv(Str, vbFromUnicode) Dim I% @@ -758,31 +747,31 @@ End If Next Exit Function -ErrHandler: +errHandler: ' return -1 End Function Private Sub cmdRegister_Click() - On Error GoTo ErrHandler + On Error GoTo errHandler ' TODO: Register this key Dim Lic As ActiveLock2.ProductLicense Set Lic = ActiveLock2.CreateProductLicense(txtName, txtSoftwareCodePub, txtVersion, _ MyActiveLock.LockType, MyActiveLock.LicenseType, _ - txtUser, GetExpirationDate(), txtLibKey) + txtUser, GetExpirationDate(), txtLibKeyIn) MyActiveLock.Register Lic MsgBox "Registration successful!" Exit Sub -ErrHandler: +errHandler: MsgBox Err.Number & ": " & Err.Description End Sub Private Sub cmdReqGen_Click() ' Generate Request code to MAC Address ' TODO: Handle other possibilities (Windows serial, etc...) - Dim strReq As String, strMAC As String - strMAC = modMACAddress.GetMACAddress() + Dim strReq As String, strLock As String + strLock = MyActiveLock.GetLockString() ' combine with user name - strReq = strMAC & vbLf & txtUser + strReq = strLock & vbLf & txtUser ' encrypt using our public key so that only us can decrypt it strReq = modMain.Encrypt(strReq) txtReqCodeGen = strReq @@ -826,11 +815,12 @@ txtRegStatus = "Registered" txtUsedDays = MyActiveLock.UsedDays txtExpiration = MyActiveLock.RegisteredDate - FunctionalitiesEnabled = False + FunctionalitiesEnabled = True Exit Sub NotRegistered: MsgBox Err.Number & ": " & Err.Description txtRegStatus = "Not Registered" + FunctionalitiesEnabled = False End Sub Private Property Let FunctionalitiesEnabled(flag As Boolean) |
From: Thanh H. T. <th...@us...> - 2003-07-23 02:57:36
|
Update of /cvsroot/activelock/activelock2/src In directory sc8-pr-cvs1:/tmp/cvs-serv4606 Modified Files: BlowFish.cls Log Message: Updated header comments. Index: BlowFish.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/BlowFish.cls,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- BlowFish.cls 8 Jul 2003 03:26:44 -0000 1.2 +++ BlowFish.cls 23 Jul 2003 02:57:34 -0000 1.3 @@ -11,29 +11,55 @@ Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = True -' /////////////////////////////////////////////////////////////////////// -' / Filename: Blowfish.cls / -' / Version: 1.0.0.1 / -' / Purpose: Store keys in a license file. / -' / (C) 2000 Fredrik Qvarfort / -' / / -' / Date Created: June 16, 2000 - FQ / -' / Date Last Modified: July 07, 2003 - MEC / -' /////////////////////////////////////////////////////////////////////// -' +'* ActiveLock +'* Copyright 2000 Fredrik Qvarfort +'* Copyright 1998-2002 Nelson Ferraz +'* Copyright 2003 The ActiveLock Software Group (ASG) +'* All material is the property of the contributing authors. +'* +'* Redistribution and use in source and binary forms, with or without +'* modification, are permitted provided that the following conditions are +'* met: +'* +'* [o] Redistributions of source code must retain the above copyright +'* notice, this list of conditions and the following disclaimer. +'* +'* [o] Redistributions in binary form must reproduce the above +'* copyright notice, this list of conditions and the following +'* disclaimer in the documentation and/or other materials provided +'* with the distribution. +'* +'* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +'* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +'* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +'* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +'* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +'* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +'* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +'* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +'* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +'* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +'* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +'* +'* + +'' +' This class implements BlowFish encryption algorithm. +' Information concerning the Blowfish algorithm can be found at: +' http://www.counterpane.com/blowfish.html +' @author fqvarfort +' @version 1.0.0 +' @date 20000616 ' +'* /////////////////////////////////////////////////////////////////////// +' / MODULE TO DO LIST / ' /////////////////////////////////////////////////////////////////////// -' / MODULE DESCRIPTION / -' /////////////////////////////////////////////////////////////////////// -' -' Information concerning the Blowfish -' algorithm can be found at: http://www.counterpane.com/blowfish.html -' ' +' [ ] + ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// - Option Explicit 'For progress notifications @@ -341,11 +367,11 @@ If (CurrPercent <> 100) Then RaiseEvent Progress(100) End Sub -Private Static Function F(ByVal X As Long) As Long +Private Static Function F(ByVal x As Long) As Long Dim xb(0 To 3) As Byte - Call CopyMem(xb(0), X, 4) + Call CopyMem(xb(0), x, 4) If (m_RunningCompiled) Then F = (((m_sBox(0, xb(3)) + m_sBox(1, xb(2))) Xor m_sBox(2, xb(1))) + m_sBox(3, xb(0))) Else |
From: Thanh H. T. <th...@us...> - 2003-07-23 02:55:36
|
Update of /cvsroot/activelock/activelock2/src In directory sc8-pr-cvs1:/tmp/cvs-serv4234 Modified Files: ActiveLock2.vbp Log Message: Removed reference to modRSA.bas - not needed. Index: ActiveLock2.vbp =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ActiveLock2.vbp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- ActiveLock2.vbp 21 Jul 2003 08:48:27 -0000 1.5 +++ ActiveLock2.vbp 23 Jul 2003 02:55:33 -0000 1.6 @@ -15,7 +15,6 @@ Module=modRegistryAPIs; modRegistryAPIs.bas Class=INIFile; INIFile.cls Module=modWinApi; modWinApi.bas -Module=modRSA; modRSA.bas Class=ActiveLockEventNotifier; ActiveLockEventNotifier.cls Module=modActiveLock; modActiveLock.bas Startup="(None)" |
From: <mc...@us...> - 2003-07-22 18:50:46
|
Hello Everyone, Over the past weeks and months we have been diligently working on ActiveLock trying to put together version 2.0. Our hard work has paid off! Sometime in the next few weeks we are going to release ActiveLock 2.0.0 Alpha. You will all be welcome to download and try out the new version of ActiveLock and provide feedback for the development team. This is a huge step for ActiveLock and we hope that you all choose to join our testing effort. I will follow up with the exact date we plan to release the alpha version tomorrow, keep your eyes open. This is one release you certainly won't want to miss. -Mike ******************************************************************* Michael E. Crute Project Manager ActiveLock Software Group (ASG) |
From: Thanh H. T. <th...@us...> - 2003-07-22 02:26:23
|
Update of /cvsroot/activelock/activelock2/src In directory sc8-pr-cvs1:/tmp/cvs-serv27827 Added Files: modBase64.bas Log Message: This module contains Base-64 encoding/decoding routines. Currently only used by ALTestApp, but may be useful to AL in the future. --- NEW FILE: modBase64.bas --- Attribute VB_Name = "modBase64" '* ActiveLock '* Copyright 1998-2002 Nelson Ferraz '* Copyright 2003 The ActiveLock Software Group (ASG) '* All material is the property of the contributing authors. '* '* Redistribution and use in source and binary forms, with or without '* modification, are permitted provided that the following conditions are '* met: '* '* [o] Redistributions of source code must retain the above copyright '* notice, this list of conditions and the following disclaimer. '* '* [o] Redistributions in binary form must reproduce the above '* copyright notice, this list of conditions and the following '* disclaimer in the documentation and/or other materials provided '* with the distribution. '* '* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS '* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT '* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR '* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT '* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, '* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT '* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, '* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY '* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT '* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE '* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. '* '* '' ' This module contains Base-64 encoding and decoding routines. ' ' @author unknown ' @version 2.0.0 ' @date unknown ' '* /////////////////////////////////////////////////////////////////////// ' / MODULE TO DO LIST / ' /////////////////////////////////////////////////////////////////////// ' ' [ ] ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CHANGE LOG / ' /////////////////////////////////////////////////////////////////////// ' ' 07.21.03 - th2tran - Added for use by ALTestApp ' ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// Option Private Module Option Explicit Option Base 0 Private Const base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" Public Function Base64_Encode(DecryptedText As String) As String Dim c1, c2, c3 As Integer Dim w1 As Integer Dim w2 As Integer Dim w3 As Integer Dim w4 As Integer Dim n As Integer Dim retry As String For n = 1 To Len(DecryptedText) Step 3 c1 = Asc(Mid$(DecryptedText, n, 1)) c2 = Asc(Mid$(DecryptedText, n + 1, 1) + Chr$(0)) c3 = Asc(Mid$(DecryptedText, n + 2, 1) + Chr$(0)) w1 = Int(c1 / 4) w2 = (c1 And 3) * 16 + Int(c2 / 16) If Len(DecryptedText) >= n + 1 Then w3 = (c2 And 15) * 4 + Int(c3 / 64) Else w3 = -1 If Len(DecryptedText) >= n + 2 Then w4 = c3 And 63 Else w4 = -1 retry = retry + mimeencode(w1) + mimeencode(w2) + mimeencode(w3) + mimeencode(w4) Next Base64_Encode = retry End Function Public Function Base64_Decode(a As String) As String Dim w1 As Integer Dim w2 As Integer Dim w3 As Integer Dim w4 As Integer Dim n As Integer Dim retry As String For n = 1 To Len(a) Step 4 w1 = mimedecode(Mid$(a, n, 1)) w2 = mimedecode(Mid$(a, n + 1, 1)) w3 = mimedecode(Mid$(a, n + 2, 1)) w4 = mimedecode(Mid$(a, n + 3, 1)) If w2 >= 0 Then retry = retry + Chr$(((w1 * 4 + Int(w2 / 16)) And 255)) If w3 >= 0 Then retry = retry + Chr$(((w2 * 16 + Int(w3 / 4)) And 255)) If w4 >= 0 Then retry = retry + Chr$(((w3 * 64 + w4) And 255)) Next Base64_Decode = retry End Function Private Function mimeencode(w As Integer) As String If w >= 0 Then mimeencode = Mid$(base64, w + 1, 1) Else mimeencode = "" End Function Private Function mimedecode(a As String) As Integer If Len(a) = 0 Then mimedecode = -1: Exit Function mimedecode = InStr(base64, a) - 1 End Function |
From: kenneth J. <jo...@pi...> - 2003-06-19 21:07:21
|
confirm 983855 |
From: Michael E. C. <mc...@so...> - 2003-06-12 21:33:03
|
Thanks I got it. ******************************************************************* Michael E. Crute Application Developer SoftGroup Development Corporation -----Original Message----- From: act...@li... [mailto:act...@li...] On Behalf Of Kirk Northrop Sent: Thursday, June 12, 2003 5:23 PM To: act...@li... Subject: [ActiveLock] Testing testing 1, 2, 3. Kirk ------------------------------------------------------- This SF.NET email is sponsored by: eBay Great deals on office technology -- on eBay now! Click here: http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5 _______________________________________________ Activelock-Development mailing list Act...@li... https://lists.sourceforge.net/lists/listinfo/activelock-development |
From: Kirk N. <li...@ne...> - 2003-06-12 21:22:55
|
1, 2, 3. Kirk |
From: Michael E. C. <mc...@so...> - 2003-06-12 19:40:54
|
******************************************************************* Michael E. Crute Application Developer SoftGroup Development Corporation -----Original Message----- From: act...@li... [mailto:act...@li...] On Behalf Of Michael E. Crute Sent: Thursday, June 12, 2003 3:29 PM To: act...@li... Subject: [ActiveLock] TEST EMAIL DELETE ME This is a test email to see if this list is really working. DO NOT REPLY. ******************************************************************* Michael E. Crute Application Developer SoftGroup Development Corporation |
From: Michael E. C. <mc...@so...> - 2003-06-12 19:29:31
|
This is a test email to see if this list is really working. DO NOT REPLY. ******************************************************************* Michael E. Crute Application Developer SoftGroup Development Corporation |