home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / RKPLUS33 / RKPLUS.DOC < prev    next >
Text File  |  1993-10-19  |  54KB  |  1,468 lines

  1.  
  2.  
  3.                R k P l u s   ( t m )   v e r s i o n   3 . 3
  4.  
  5.                   Turbo Pascal (tm) Registration Key Unit
  6.  
  7.                              by C. Scott Davis
  8.  
  9.                  Copyright (c) 1991-93 Serious Cybernetics
  10.  
  11.            6804 Belton Place  *  Lula, GA  *  30554-2622  *  USA
  12.  
  13.  
  14.  
  15.                     RkPlus(tm) 3.3 Registration key Unit
  16.                      T A B L E   O F   C O N T E N T S
  17.  
  18.     ===================================================================
  19.  
  20.         D e s c r i p t i o n                                  Sec
  21.  
  22.         What Is RkPlus(tm)? ................................   1.0
  23.         Getting Started With RkPlus(tm) ....................   2.0
  24.         Five Methods Of Using RkPlus(tm) ...................   3.0
  25.         RkPlus(tm) Type Definitions ........................   4.0
  26.         RkPlus(tm) Constants ...............................   5.0
  27.         RkPlus(tm) Variables ...............................   6.0
  28.         RkPlus(tm) Functions And Procedures ................   7.0
  29.         Detailed Type Information ..........................   8.0
  30.         RkpRec .............................................   8.1
  31.         EncFuncType ........................................   8.2
  32.         FileFuncType .......................................   8.3
  33.         Detailed Constant Information ......................   9.0
  34.         NoError ............................................   9.1
  35.         FileNotFound .......................................   9.2
  36.         PathNotFound .......................................   9.3
  37.         TooManyFiles .......................................   9.4
  38.         AccessDenied .......................................   9.5
  39.         InvalidFile ........................................   9.6
  40.         InvalidRecord / RecordNotFound .....................   9.7
  41.         InvalidParameter ...................................   9.8
  42.         VersionMismatch ....................................   9.9
  43.         NoEncodeFunc .......................................   9.10
  44.         InvalidKey .........................................   9.11
  45.         ExpiredKey .........................................   9.12
  46.         BadTPU .............................................   9.13
  47.         Detailed Variable Information ......................   10.0
  48.         BaseYear ...........................................   10.1
  49.         UseExpDays .........................................   10.2
  50.         UseExePath .........................................   10.3
  51.         KeyFileSize ........................................   10.4
  52.         Rkp.Registered .....................................   10.5
  53.         Rkp.ID .............................................   10.6
  54.         Rkp.Name1 ..........................................   10.7
  55.         Rkp.Name2 ..........................................   10.8
  56.         Rkp.Name3 ..........................................   10.9
  57.         Rkp.Message ........................................   10.10
  58.         Rkp.Level ..........................................   10.11
  59.         Rkp.ExpYear / Rkp.ExpMonth / Rkp.Day ...............   10.12
  60.         Rkp.Key ............................................   10.13
  61.         KeyFileCode ........................................   10.14
  62.         Detailed Procedure And Function Information ........   11.0
  63.         RkPlusVer ..........................................   11.1
  64.         BadSystemDate ......................................   11.2
  65.         RkpOK ..............................................   11.3
  66.         RkpError ...........................................   11.4
  67.         SetEncode ..........................................   11.5
  68.         SetKeyFile .........................................   11.6
  69.         KeyFileName ........................................   11.7
  70.         ExeFileName ........................................   11.8
  71.         GetKeyFileSize .....................................   11.9
  72.         MakeKey ............................................   11.10
  73.         ValidKey ...........................................   11.11
  74.         SetRegInfo .........................................   11.12
  75.         CreateKey ..........................................   11.13
  76.         VerifyKey ..........................................   11.14
  77.         GetRegInfo .........................................   11.15
  78.         SaveRegInfo ........................................   11.16
  79.         BrandRegInfo .......................................   11.17
  80.         SetFileEnc .........................................   11.18
  81.         Additional Information On RkPlus(tm) ...............   12.0
  82.         RkPlus(tm) Source Code Availability ................   13.0
  83.         What's Next For RkPlus(tm)? ........................   14.0
  84.         ShareWare Notice And Registration ..................   15.0
  85.         RkPlus(tm) Support .................................   16.0
  86.         Credits ............................................   17.0
  87.         Turbo Pascal (tm) Units from Serious Cybernetics ...   18.0
  88.         Other Recommended Turbo Pascal (tm) Units ..........   19.0
  89.         Copyright Notices ..................................   20.0
  90.  
  91.  
  92.  
  93.  
  94. 1.0 - What is RkPlus(tm)?
  95.  
  96. RkPlus(tm) is an enhanced version of our original rKey Registration Key 
  97. Unit.  It is a Turbo Pascal (tm) Unit designed to allow programmers to 
  98. easily handle secure registration keys in their software.  All of the key 
  99. encryption, checking, and key file routines are handled in RkPlus(tm), 
  100. requiring little effort on the part of the programmer.  RkPlus(tm) can allow 
  101. anything from simple registration messages to multiple registration levels, 
  102. limited use demo keys, and custom written encoding functions.
  103.  
  104. There are seven versions of RkPlus included within the main RKPLUS33 
  105. distribution archive, each in it's own unique archive :
  106.  
  107.  RKP50TPU - RkPlus(tm) for Turbo Pascal (tm) 5.0
  108.             Contains RKPLUS.TPU, RKP2ENC.TPU and RKP3ENC.TPU
  109.  
  110.  RKP55TPU - RkPlus(tm) for Turbo Pascal (tm) 5.5
  111.             Contains RKPLUS.TPU, RKP2ENC.TPU and RKP3ENC.TPU
  112.  
  113.  RKP60TPU - RkPlus(tm) for Turbo Pascal (tm) 6.0
  114.             Contains RKPLUS.TPU, RKP2ENC.TPU and RKP3ENC.TPU
  115.  
  116.  RKP10TPU - RkPlus(tm) for Turbo Pascal (tm) 1.0 for Windows (tm)
  117.             Contains RKPLUS.TPU, WDCOMPAT.TPU, RKP2ENC.TPU and RKP3ENC.TPU
  118.  
  119.  RKP15TPU - RkPlus(tm) for Turbo Pascal (tm) 1.5 for Windows (tm)
  120.             Contains RKPLUS.TPU, WDCOMPAT.TPU, RKP2ENC.TPU and RKP3ENC.TPU
  121.  
  122.  RKP70TPU - RkPlus(tm) for Borland/Turbo Pascal (tm) 7.0
  123.             Contains RKPLUS.TPU, RKP2ENC.TPU, RKP3ENC.TPU,
  124.             RKPLUS.TPP, RKP2ENC.TPP, RKP3ENC.TPP,
  125.             RKPLUS.TPW, WDCOMPAT.TPW, RKP2ENC.TPW and RKP3ENC.TPW
  126.  
  127.  RKPSBP - RkPlus(tm) for Stony Brook Pascal+(tm)
  128.           Contains RKPLUS.SBL, RKPLUS.LIB, RKP2ENC.LIB, RKP3ENC.LIB,
  129.           RKPLUS.INT, RKP2ENC.INT, and RKP3ENC.INT.
  130.  
  131. Note:  If you use a specific version of Turbo Pascal (tm), be sure to 
  132. extract the RkPlus(tm) files from the proper internal archive!  Using the 
  133. wrong version of RkPlus(tm) is sure to cause problems.  For instance, if you 
  134. program using Turbo Pascal (tm) version 6.0, be sure you are using the 
  135. RkPlus(tm) files from the RKP60TPU archive!
  136.  
  137. Within this documentation are many examples and Turbo Pascal (tm) code 
  138. segments.  These segments are necessarily brief, but should be sufficient to 
  139. explain the various functions of RkPlus(tm).  Due to restrictions necessary 
  140. when distributing and modifying a text document of this nature, all 
  141. pagination has been removed from this document.  A complete professionally 
  142. printed and bound manual is available for RkPlus(tm) for a nominal fee (see 
  143. section 15.0 on registration).
  144.  
  145.  
  146. 2.0 - Getting Started with RkPlus(tm)
  147.  
  148. There are basically 3 approaches to using RkPlus(tm) :
  149.  
  150. 1)  If you have an existing programme written using RkPlus(tm) version 2.x 
  151. (2.0 to 2.4), and you want to maintain compatibility with your existing 
  152. keys, you can simply use the Rkp2Enc unit.  This unit contains RkPlus(tm) 
  153. version 2.x/compatible encoding routines and automatically interfaces itself 
  154. with RkPlus(tm).  Examples of this approach are contained in the RKPDEMO2 
  155. archive.
  156.  
  157. 2)  If you don't want to write your own encoding functions (but don't 
  158. require RkPlus(tm) 2.x compatibility), you can simply use the Rkp3Enc unit.  
  159. This unit contains new RkPlus(tm) version 3.x encoding routines and 
  160. automatically interfaces itself with RkPlus(tm).  Examples of this approach 
  161. are contained in the RKPDEMO3 archive.
  162.  
  163. 3)  If you want to be totally assured of the uniqueness and security of your 
  164. keys, you can write your own encoding functions and specify them with the 
  165. SetEncode procedure (see "SetEncode" in section 11.5).  This is somewhat 
  166. more involved that the first approach, but gives you more control of key 
  167. generation.  Examples of this approach are contained in the RKPDEMO archive.
  168.  
  169.  
  170. 3.0 - Five Methods of Using RkPlus(tm)
  171.  
  172. The various sample programmes demonstrate 5 methods of handling keys :
  173.  
  174. 1)  Distribute your programme (see SAMPLE1.PAS) and use a key file 
  175. generation programme (see GENFILE.PAS), which you do NOT distribute, to 
  176. create a key file for each user who registers.  You then send the user the 
  177. key file.
  178.  
  179. 2)  Distribute your programme (see SAMPLE1.PAS) and a registration programme 
  180. (see REGISTER.PAS).  You then use a key generation programme (see 
  181. GENKEY.PAS), which you do NOT distribute, to create a key number for each 
  182. user who registers.  You then send the user the key number, which he/she 
  183. enters into the registration programme to create a key file.
  184.  
  185. 3)  Distribute your programme (see SAMPLE2.PAS), which has it's own 
  186. registration routine.  You then use a key generation programme (see 
  187. GENKEY.PAS), which you do NOT distribute, to create a a key number for each 
  188. user who registers.  You then send the user the key number, which he/she 
  189. enters into the programme to create a key file.
  190.  
  191. 4)  Distribute your programme (see SAMPLE3.PAS), which has its own 
  192. configuration file.  You then use a key generation programme (see 
  193. GENKEY.PAS), which you do NOT distribute, to create a a key number for each 
  194. user who registers.  You then send the user the key number, which he/she 
  195. enters into the configuration file. There is no key file required with this 
  196. method.
  197.  
  198. 5)  Distribute your programme (see SAMPLE4.PAS) and a branding programme 
  199. (see BRAND.PAS).  You then use a key generation programme (see GENKEY.PAS), 
  200. which you do NOT distribute, to create a key number for each user who 
  201. registers. You then send the user the key number, which he/she enters into 
  202. the branding programme to write the registration information directly into 
  203. the EXE file.
  204.  
  205.  
  206. 4.0 - RkPlus(tm) Type Definitions
  207.  
  208. The following Types are defined in RkPlus(tm).  See section 8 for details on 
  209. each.
  210.  
  211. RkpRec
  212. EncFuncType
  213. FileFuncType
  214.  
  215.  
  216. 5.0 - RkPlus(tm) Constants
  217.  
  218. The following Constants are defined in RkPlus(tm).  See section 9 for 
  219. details on each.
  220.  
  221. NoError
  222. FileNotFound
  223. PathNotFound
  224. TooManyFiles
  225. AccessDenied
  226. InvalidFile
  227. InvalidRecord
  228. RecordNotFound
  229. InvalidParameter
  230. VersionMismatch
  231. NoEncodeFunc
  232. InvalidKey
  233. ExpiredKey
  234. BadTPU
  235.  
  236.  
  237. 6.0 - RkPlus(tm) Variables
  238.  
  239. The following Variables are defined in RkPlus(tm).  See section 10 for 
  240. details on each.
  241.  
  242. BaseYear
  243. UseExpDays
  244. UseExePath
  245. KeyFileSize
  246. Rkp
  247. KeyFileCode
  248.  
  249.  
  250. 7.0 - RkPlus(tm) Procedures and Functions
  251.  
  252. The following Procedures and Functions are defined in RkPlus(tm).  See 
  253. section 11 for details on each.
  254.  
  255. Functions:
  256.   RkPlusVer
  257.   BadSystemDate
  258.   RkpOK
  259.   RkpError
  260.   KeyFileName
  261.   ExeFileName
  262.   GetKeyFileSize
  263.   MakeKey
  264.   ValidKey
  265.  
  266. Procedures:
  267.   SetEncode
  268.   SetKeyFile
  269.   SetRegInfo
  270.   CreateKey
  271.   VerifyKey
  272.   GetRegInfo
  273.   SaveRegInfo
  274.   BrandRegInfo
  275.   SetFileEnc
  276.  
  277.  
  278. 8.0 - Detailed Type Information
  279.  
  280. This section contains detailed information on all Types defined in 
  281. RkPlus(tm).
  282.  
  283.  
  284. 8.1 - RkpRec
  285.  
  286. RkpRec      = Record
  287.                 Registered : Boolean;
  288.                 ID         : String[36];
  289.                 Name1      : String[36];
  290.                 Name2      : String[36];
  291.                 Name3      : String[36];
  292.                 Message    : String[36];
  293.                 Level      : Byte;
  294.                 ExpYear    : Word;
  295.                 ExpMonth   : Byte;
  296.                 ExpDay     : Byte;
  297.                 Key        : String[12];
  298.               End;
  299.  
  300.  
  301. RkpRec is the Type used by the variable Rkp, which contains the registration 
  302. information (see "Detailed Variable Information" in section 10).
  303.  
  304.  
  305. 8.2 - EncFuncType
  306.  
  307. EncFuncType = Function(t1,t2,t3 : String; l : Byte; i : Integer) : Word;
  308.  
  309. EncFuncType is the function type used to define a custom encoding function 
  310. (see "SetEncode" in section 11.5).
  311.   
  312.  
  313. 8.3 - FileFuncType
  314.  
  315. FileFuncType = Function(v : Byte; b : Boolean) : Byte;
  316.  
  317. This type defines the function type that would be passed to SetFileEnc, when 
  318. specifying a File Encoding Function (see SetFileEnc).  It is automatically 
  319. set by Rkp2Enc and Rkp3Enc.  You will only need to use FileFuncType if you 
  320. are using user-written encoding functions.
  321.  
  322.  
  323. 9.0 - Detailed Constant Information
  324.  
  325. This section contains detailed information on all Constants interfaced by 
  326. RkPlus(tm).  The constants defined by RkPlus(tm) are used to define values 
  327. that may be returned by RkpError (Section 11.4).  In addition to those 
  328. defined as constants, error codes $0001 to $00FF correspond to the values 
  329. returned by the Turbo Pascal (tm) IoResult function.
  330.  
  331.  
  332. 9.1 - NoError
  333.  
  334. NoError          = $0000;
  335.  
  336. If RkpError returns NoError then no error has occurred.  If this is the 
  337. case, then RkpOK will also return True.  If RkpError returns any non-zero 
  338. value, then RkpOK will return False.
  339.  
  340.  
  341. 9.2 - FileNotFound
  342.  
  343. FileNotFound     = $0002;
  344.  
  345. If RkpError returns FileNotFound then the previous function or procedure was 
  346. unable to find a required file.
  347.  
  348.  
  349. 9.3 - PathNotFound
  350.  
  351. PathNotFound     = $0003;
  352.  
  353. If RkpError returns PathNotFound then the previous function or procedure was 
  354. unable to find the path of a required file.
  355.  
  356.  
  357. 9.4 - TooManyFiles
  358.  
  359. TooManyFiles     = $0004;
  360.  
  361. If RkpError returns TooManyFiles then RkPlus(tm) was unable to open a file 
  362. because not enough file handles were defined in CONFIG.SYS.
  363.  
  364.  
  365. 9.5 - AccessDenied
  366.  
  367. AccessDenied     = $0005;
  368.  
  369. If RkpError returns AccessDenied then an attempt was made to write to a Read 
  370. Only file or a currently open shared file.
  371.  
  372.  
  373. 9.6 - InvalidFile
  374.  
  375. InvalidFile      = $0101;
  376.  
  377. If RkpError returns InvalidFile then the previous function or procedure 
  378. attempted to process a file that is not a valid RkPlus(tm) file.
  379.  
  380.  
  381. 9.7 - InvalidRecord / RecordNotFound
  382.  
  383. InvalidRecord    = $0102;
  384. RecordNotFound   = $0103;
  385.  
  386. These errors are not returned by RkpError, but are included for future use 
  387. and compatibility with other Serious Cybernetics units.
  388.  
  389.  
  390. 9.8 - InvalidParameter
  391.  
  392. InvalidParameter = $0201;
  393.  
  394. If RkpError returns InvalidParameter, then the previous function or 
  395. procedure was passed invalid data.
  396.  
  397.  
  398. 9.9 - VersionMismatch
  399.  
  400. VersionMismatch  = $0202;
  401.  
  402. This error is not currently used by RkPlus(tm), but is included for future 
  403. use and is presently used by the encoding units (Rkp2Enc and Rkp3Enc).
  404.  
  405.  
  406. 9.10 - NoEncodeFunc
  407.  
  408. NoEncodeFunc     = $0301;
  409.  
  410. If RkpError returns NoEncodeFunc then you are attempting to use RkPlus(tm) 
  411. without either providing a custom encode function or using one of the 
  412. encoding units (Rkp2Enc or Rkp3Enc), both of which automatically set their 
  413. encode functions.
  414.  
  415.  
  416. 9.11 - InvalidKey
  417.  
  418. InvalidKey       = $0302;
  419.  
  420. If RkpError returns InvalidKey then the current key in the Rkp record 
  421. (Rkp.Key) is not valid.
  422.  
  423.  
  424. 9.12 - ExpiredKey
  425.  
  426. ExpiredKey       = $0303;
  427.  
  428. If RkpError returns ExpiredKey then the current key in the Rkp record 
  429. (Rkp.Key) has expired.
  430.  
  431.  
  432. 9.13 - BadTPU
  433.  
  434. BadTPU           = $FFFF;
  435.  
  436. If RkpError returns BadTPU then the RKPLUS.TPU file is corrupt or has been 
  437. tampered with and SHOULD BE REPLACED IMMEDIATELY.
  438.  
  439.  
  440. 10.0 - Detailed Variable Information
  441.  
  442. This section contains detailed information on all Variables interfaced by 
  443. RkPlus(tm).
  444.  
  445.  
  446. 10.1 - BaseYear
  447.  
  448. BaseYear : Word;
  449.  
  450. This variable contains the base year that will be used when calculating 
  451. expiration keys.  It is initialised to 1992 by RkPlus(tm).  It is VERY 
  452. important that the value of BaseYear be the same in the programme that 
  453. generated the key and the programme that uses it, otherwise expiration dates 
  454. will be calculated incorrectly.
  455.  
  456. Example :
  457.  
  458. BaseYear := 1990;
  459.  
  460. All expiration dates will be calculated and stored as offsets from 
  461. 1-Jan-1990.
  462.  
  463.  
  464. 10.2 - UseExpDays
  465.  
  466. UseExpDays : Boolean;
  467.  
  468. This variable determines whether expiration days will be included in 
  469. expiration dates for keys.  If UseExpDays is True (default), then expiration 
  470. days will be included (allowing a valid range of 21 years).  If UseExpDays 
  471. is False, then expiration days will not be included (allowing a valid range 
  472. of 304 years).  If expiration days are not used, keys will expire on the 
  473. first day of the expiration month.  The Rkp2Enc unit sets UseExpDays to 
  474. False to maintain compatibility with RkPlus(tm) version 2.x keys.
  475.  
  476.  
  477. 10.3 - UseExePath
  478.  
  479. UseExePath : Boolean;
  480.  
  481. This variable controls how RkPlus(tm) handles filenames with no specified 
  482. path. If UseExePath is True (default), then RkPlus(tm) will use the path 
  483. that the programme was executed from if no path is specified.  If UseExePath 
  484. is False, then RkPlus(tm) will use the current path if no path is specified.
  485.  
  486.  
  487. 10.4 - KeyFileSize
  488.  
  489. KeyFileSize : Integer;
  490.  
  491. This variable is used by SaveRegInfo to determine the size of the key file 
  492. when it is created.  If KeyFileSize is less than or equal to 337 (the number 
  493. of bytes used by RkPlus(tm)), the file will be 337 bytes long.  However, if 
  494. KeyFileSize is greater than 337, random bytes will be appended to the key 
  495. file to cause it to be KeyFileSize bytes long.
  496.  
  497. Example :
  498.  
  499. KeyFileSize := 1024;
  500. Randomize;
  501.  
  502. Any future calls to SaveRegInfo will result in a key file that has been 
  503. padded to 1024 bytes.
  504.  
  505. Note:  RkPlus(tm) does NOT automatically randomize the seed number used to 
  506. generate the random bytes that are appended to the key file.  In order to 
  507. have true random values, your programme must call the Randomize procedure 
  508. before SaveRegInfo is called.  If you are not using KeyFileSize (it is less 
  509. than or equal to 337), then you do not need to call Randomize (since no 
  510. random bytes will be appended).
  511.  
  512.  
  513. 10.5 - Rkp.Registered
  514.  
  515. Rkp.Registered : Boolean;
  516.  
  517. This field of the Rkp record is initialised by RkPlus(tm) to False.  It is 
  518. set by CreateKey, VerifyKey, GetRegInfo, SaveRegInfo, and BrandRegInfo to 
  519. True if the current key contained in Rkp.Key is valid and has not expired.
  520.  
  521. Example :
  522.  
  523. If Rkp.Registered then
  524.  
  525. The code following would only be executed if the programme has been 
  526. registered. This assumes, of course, that an RkPlus(tm) procedure (such as 
  527. GetRegInfo or VerifyKey) has been called previously.
  528.  
  529.  
  530. 10.6 - Rkp.ID
  531.  
  532. Rkp.ID : String[36];
  533.  
  534. This variable is initialised by RkPlus(tm) to ''.  Rkp.ID is not used by 
  535. RkPlus(tm), and has no effect on key encryption.  However, it is read from 
  536. the key file by GetRegInfo, written to the key file by SaveRegInfo, and 
  537. branded into the EXE file by BrandRegInfo.  This will normally be used to ID 
  538. your key files, so that your programme can distinguish its own key files 
  539. from those of other programmes. However, since it is not used in the 
  540. encryption of the registration key, it can be used to store any information 
  541. that you want.
  542.  
  543. Example :
  544.  
  545. If (Rkp.ID <> 'RkData') then
  546.   WriteLn('Error!  This is NOT an RkData key file!');
  547.  
  548. If Rkp.ID doesn't equal 'RkData' then the message 'Error!  This is NOT an 
  549. RkData key file!' will be displayed.
  550.  
  551.  
  552. 10.7 - Rkp.Name1
  553.  
  554. Rkp.Name1 : String;
  555.  
  556. This variable is initialised by RkPlus(tm) to ''.  It is used (along with 
  557. Rkp.Name2 and Rkp.Name3) in the encryption of the registration key by 
  558. CreateKey, VerifyKey, SaveRegInfo (which also writes it to the key file), 
  559. and BrandRegInfo (which also brands it to the EXE file).  It is read from 
  560. the key file by GetRegInfo.  This will normally contain the name of the 
  561. person that the software is registered to.
  562.  
  563. Example :
  564.  
  565. If Rkp.Registered then
  566.   WriteLn('Registered to ',Rkp.Name1)
  567. Else
  568.   WriteLn('Unregistered')
  569.  
  570. If the programme is registered, it will display the name of the person it is 
  571. registered to.  Otherwise, it will display "Unregistered".
  572.  
  573.  
  574. 10.8 - Rkp.Name2
  575.  
  576. Rkp.Name2 : String;
  577.  
  578. This variable is initialised by RkPlus(tm) to ''.  It is used (along with 
  579. Rkp.Name1 and Rkp.Name3) in the encryption of the registration key by 
  580. CreateKey, VerifyKey, SaveRegInfo (which also writes it to the key file), 
  581. and BrandRegInfo (which also brands in to the EXE file).  It is read from 
  582. the key file by GetRegInfo.  This may contain a company name, a BBS name, or 
  583. any additional information that you want to use in key encryption.
  584.  
  585. Example :
  586.  
  587. If Rkp.Registered then Begin
  588.   WriteLn('Registered to ',Rkp.Name1,'.');
  589.   WriteLn('For use at ',Rkp.Name2,'.');
  590. End Else
  591.   WriteLn('Remember to Register!');
  592.  
  593. If the programme is registered, it will display the name and company of the 
  594. user that it is registered to.  Otherwise, it will display "Remember to 
  595. Register!".
  596.  
  597.  
  598. 10.9 - Rkp.Name3
  599.  
  600. Rkp.Name3 : String;
  601.  
  602. This variable is initialised by RkPlus(tm) to ''.  It is used (along with 
  603. Rkp.Name1 and Rkp.Name2) in the encryption of the registration key by 
  604. CreateKey, VerifyKey, SaveRegInfo (which also writes it to the key file), 
  605. and BrandRegInfo (which also brands it into the EXE file).  It is read from 
  606. the key file by GetRegInfo.  This may contain a customer number, address, or 
  607. any additional information that you want to use in key encryption.
  608.  
  609. Example :
  610.  
  611. If Rkp.Registered then Begin
  612.   WriteLn('Registered to ',Rkp.Name1);
  613.   WriteLn('              ',Rkp.Name2);
  614.   WriteLn('              ',Rkp.Name3);
  615. End Else
  616.   WriteLn('Unregistered')
  617.  
  618. If the programme is registered, it will display the name of the person it is 
  619. registered to followed by a 2 line address (from Rkp.Name2 and Rkp.Name3). 
  620. Otherwise, the message 'Unregistered' will be displayed.
  621.  
  622.  
  623. 10.10 - Rkp.Message
  624.  
  625. Rkp.Message : String[36];
  626.  
  627. This variable is initialised by RkPlus(tm) to ''.  Rkp.Message is not used by 
  628. RkPlus(tm), and has no effect on key encryption.  However, it is read from the 
  629. key file by GetRegInfo, written to the key file by SaveRegInfo, and branded to 
  630. the EXE file by BrandRegInfo.  This will normally be used to ID your key 
  631. files, so that your programme can distinguish your key files from those of 
  632. other programers/companies.  However, since it is not used in the encryption 
  633. of the registration key, it can be used to store any information that you 
  634. want.
  635.  
  636. Example :
  637.  
  638. If(Rkp.Message <> 'Serious Cybernetics') then
  639.   WriteLn('Error!  This is NOT a Serious Cybernetics key file!');
  640.  
  641. If Rkp.Message doesn't equal 'Serious Cybernetics', then the message 'Error! 
  642. This is NOT a Serious Cybernetics key file!' will be displayed.
  643.  
  644.  
  645. 10.11 - Rkp.Level
  646.  
  647. Rkp.Level : BYTE;
  648.  
  649. This variable is initialised by RkPlus(tm) to 0.  It is used in the 
  650. encryption of the registration key by CreateKey, VerifyKey, SaveRegInfo 
  651. (which also writes it to the key file), and BrandRegInfo (which also brands 
  652. it to the EXE file). It is read from the key file by GetRegInfo. If you 
  653. don't wish to use registration levels, Rkp.Level should always be 0.
  654.  
  655. Example :
  656.  
  657. If Rkp.Level > 0 then
  658.   WriteLn('[G]raphs');
  659. If Rkp.Level > 1 then
  660.   WriteLn('[O]ther functions');
  661.  
  662. If the registration level is greater than 0 then the menu option "[G]raphs" 
  663. would be displayed.  If the registration level is greater than 1 then the 
  664. menu option "[O]ther functions" would also be displayed.
  665.  
  666. Note : Unlike the expiration date, which is binary encoded into the key 
  667. number (after the encoding functions are called) and therefore can be 
  668. extracted from any given key number, the registration level is only used for 
  669. the encryption of the key, and is stored in the key file but can not be 
  670. extracted from a key number itself.  Therefore, if you use registration 
  671. levels, you will need to make sure that the brand programme or key file 
  672. creation programme knows, or can determine, the registration level, because 
  673. it can NOT be extracted from the key number alone (see SAMPLE2.PAS, 
  674. REGISTER.PAS, and BRAND.PAS for examples).
  675.  
  676.  
  677. 10.12 - Rkp.ExpYear, Rkp.ExpMonth, Rkp.Day
  678.  
  679. Rkp.ExpYear  : Word;
  680. Rkp.ExpMonth : Byte;
  681. Rkp.ExpDay   : Byte;
  682.  
  683. These variables are initialised by RkPlus(tm) to 0.  They are binary-encoded 
  684. into the registration key by CreateKey, SaveRegInfo, and BrandRegInfo.  They 
  685. are decoded from the registration key by VerifyKey and GetRegInfo.  Valid 
  686. values for Rkp.ExpYear are 0 (No expiration) or BaseYear+1 to BaseYear+340 
  687. (if UseExpDays is False) or BaseYear+1 to BaseYear+21 (if UseExpDays is 
  688. True) . Valid values for Rkp.ExpMonth are 0 (No expiration) or 1 to 12.  
  689. Valid values for Rkp.ExpDay are 0 (No expiration) or odd days 1 to 29 (if 
  690. UseExpDays is True). Even values (1 to 28) will be rounded up to the next 
  691. odd value.  If you don't wish to use expiration dates, Rkp.ExpYear, 
  692. Rkp.ExpMonth, and Rkp.ExpDay should always be 0.
  693.  
  694. Example :
  695.  
  696. Const
  697.  Months : Array[1..12] of String[3] =
  698.  ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
  699.  
  700. BaseYear := 1990;
  701. UseExpDays := False;
  702. .
  703. . { rest of programme would be here }
  704. .
  705. If (RkpError = ExpiredKey) then
  706.   WriteLn('Your key expired 1-',Months(Rkp.ExpMonth),'-',Rkp.ExpYear)
  707. Else If Rkp.Registered then
  708.   WriteLn('Your key will expire 1-',Months(Rkp.ExpMonth),'-',Rkp.ExpYear);
  709.  
  710. If the key has expired, the date that the key expired is displayed. 
  711. Otherwise, if the programme is registered, the date that the key will expire 
  712. is displayed.
  713.  
  714.  
  715. 10.13 - Rkp.Key
  716.  
  717. Rkp.Key : String[12];
  718.  
  719. This variable is initialised by RkPlus(tm) to '000000000000'.  It is set by 
  720. CreateKey and GetRegInfo.  It is used by VerifyKey, SaveRegInfo, and 
  721. BrandRegInfo.  This contains the 12 digit alphanumeric registration key as a 
  722. string.
  723.  
  724. Example :
  725.  
  726. If Rkp.Registered then Begin
  727.   WriteLn('Registered to ',Rkp.Name1,'.');
  728.   WriteLn('Registration key is ',Rkp.Key,'.');
  729. End Else
  730.   WriteLn('Not registered.');
  731.   WriteLn('Please read the READ.ME file for more info.');
  732. End;
  733.  
  734. If the programme is registered, the name of the person that it is registered 
  735. to, and the registration key will be displayed.  Otherwise, a message will 
  736. be displayed telling the user how to register the programme.
  737.  
  738.  
  739. 10.14 - KeyFileCode
  740.  
  741. KeyFileCode : LongInt;
  742.  
  743. This variable defaults to 0 (no KeyFile scrambling).  If it set to any valid 
  744. non-zero value ($00000001 to $FFFFFFFF) then it will be used to generate an 
  745. algorythm to "scramble" the key file as it is written.  If KeyFileCode is 
  746. not set to the exact same value in programmes which read the key file, the 
  747. file will be unreadable.
  748.  
  749. KeyFileCode is designed to prevent hackers from being able to use a copy of 
  750. RkPlus(tm) to read your key files.  It has the additional effect of making 
  751. the key file illegible when listed by text file viewers.
  752.  
  753.  
  754. 11.0 - Detailed Procedure And Function Information
  755.  
  756. The following procedure and functions are available when using the 
  757. RkPlus(tm) TPU:
  758.  
  759.  
  760. 11.1 - RkPlusVer
  761.  
  762. Function RkPlusVer : String;
  763.  
  764. RkPlusVer returns the current version of RkPlus(tm).
  765.  
  766. Example :
  767.  
  768. WriteLn('using ',RkPlusVer);
  769.  
  770. will display "using RkPlus 3.3".
  771.  
  772.  
  773. 11.2 - BadSystemDate
  774.  
  775. Function BadSystemDate : Boolean;
  776.  
  777. This Function will return True if the current system date is 1-Jan-1980 
  778. (which usually indicates that the date was not set on the PC), or False if 
  779. the current system date is anything other than 1-Jan-1980.
  780.  
  781. The main purpose for this Function is for use with limited keys (with 
  782. embedded expiration dates).  By calling BadSystemDate, your programme can 
  783. handle situations where the system date was not set (which would cause 
  784. expiration dates to be meaningless).
  785.  
  786. Example :
  787.  
  788. If BadSystemDate then Begin
  789.   WriteLn('The system date must be set!');
  790.   Halt(1);
  791. End;
  792.  
  793. If the system date was not set (BadSystemDate returns True) then display a 
  794. message and exit with an ErrorLevel of 1.
  795.  
  796.  
  797. 11.3 -  RkpOK
  798.  
  799. Function RkpOK : Boolean;
  800.  
  801. RkpOK will return True if the result of the last procedure or function was 
  802. NoError.  If RkpOK is False, then an error has occurred.
  803.  
  804. Example :
  805.  
  806. If RkpOK then
  807.   WriteLn('Key file written!');
  808.  
  809. If RkpOk returns True, then the message "Key file written!" will be 
  810. displayed.
  811.  
  812.  
  813. 11.4 - RkpError
  814.  
  815. Function RkpError : Word;
  816.  
  817. RkpError will return the actual error code of the last procedure/function. 
  818. If RkpError = NoError, then no error occurred.  If RkpError is between $0001 
  819. and $00FF, then an I/O error occurred during the operation and the result is 
  820. an IoResult code.  Otherwise, the error is an RkPlus(tm) error (see 
  821. "Detailed Constant Information").
  822.  
  823. Example :
  824.  
  825. If RkpOK then
  826.   WriteLn('Key file written.')
  827. Else
  828.   WriteLn('Error ',RkpError,'!');
  829.  
  830. If no error occurred, "Key file written." will be displayed.  Otherwise, the 
  831. error code will be displayed.
  832.  
  833.  
  834. 11.5 - SetEncode
  835.  
  836. Procedure SetEncode(e1, e2, e3 : EncFuncType);
  837.  
  838. This procedure will specify the functions that will be called to encode the 
  839. registration key.  An encoding function must be defined as FAR {$F+} and 
  840. must be of the type EncFuncType.  Each encode function is used to encode one 
  841. 4-character section of the final key number (the actual number to character 
  842. conversion is handled by RkPlus(tm)) and is passed 3 strings, a Byte and an 
  843. Integer.  Any or all of these values may be used by any single encode 
  844. function to produce a Word result. However, the 3 Strings and the Byte 
  845. should be used in at least one of the encode functions.  Otherwise, that 
  846. value will have no effect on key generation.  The 3 strings correspond to 
  847. Rkp.Name1, Rkp.Name2 and Rkp.Name3. The Byte corresponds to the registration 
  848. level (Rkp.Level) and the Integer is the expiration date stored as an offset 
  849. from 1-Jan of BaseYear. Since the expiration date will be binary-encoded 
  850. into the key number after the encode function returns, it is not required 
  851. that it be used in the encode function.  If you use Rkp2Enc (for RkPlus(tm) 
  852. 2.x/compatible keys) or Rkp3Enc (for RkPlus(tm) 3.x keys), you do not need 
  853. to provide encoding functions or call SetEncode (it is handled automatically 
  854. in the encoding unit's startup code).
  855.  
  856.  
  857. 11.6 - SetKeyFile
  858.  
  859. Procedure SetKeyFile(s : String);
  860.  
  861. This procedure will specify the name of the key file for RkPlus(tm) to use 
  862. (with optional path and extension).  The key file will default to the name 
  863. of the programme with an extension of '.RKP' (or '.EXE' when using 
  864. BrandRegInfo) and the path will default to the path the programme was 
  865. executed from (if UseExePath is True) or the current directory (if 
  866. UseExePath is False).
  867.  
  868. Example :
  869.  
  870. UseExePath := False;
  871. SetKeyFile('DEMO1');
  872.  
  873. RkPlus(tm) will use 'DEMO1.RKP' (in the current directory) as the key file.  
  874. If BrandRegInfo is called, it will use 'DEMO1.EXE' (in the current 
  875. directory).
  876.  
  877.  
  878. 11.7 - KeyFileName
  879.  
  880. Function KeyFileName : String;
  881.  
  882. This function will return the full path, filename and extension of the key 
  883. file.
  884.  
  885. Example :
  886.  
  887. UseExePath := True;
  888. SetKeyFile('DEMO2');
  889. WriteLn(KeyFileName);
  890.  
  891. If the current directory is (for example) D:\ and the programme was executed 
  892. from (for example) C:\DEMOS, then it would display "C:\DEMOS\DEMO2.RKP".
  893.  
  894.  
  895. 11.8 - ExeFileName
  896.  
  897. Function ExeFileName : String;
  898.  
  899. This function will return the full path, filename and extension of the exe 
  900. file that would be branded by BrandRegInfo.  This will be identical to the 
  901. result of KeyFileName, except that the extension will be '.EXE'.
  902.  
  903. Example :
  904.  
  905. UseExePath := False;
  906. SetKeyFile('DEMO3');
  907. WriteLn(ExeFileName);
  908.  
  909. If the current directory is (for example) D:\ and the programme was executed 
  910. from (for example) C:\DEMOS, then it would display "D:\DEMO3.EXE".
  911.  
  912.  
  913. 11.9 - GetKeyFileSize
  914.  
  915. Function GetKeyFileSize : Integer;
  916.  
  917. This Function will return the size (in bytes) of the key file.
  918.  
  919. Example :
  920.  
  921. If (GetKeyFileSize <> 1024) then
  922.   WriteLn('Invalid file size');
  923.  
  924. If the size of the key file is not equal to 1024, then "Invalid File Size" 
  925. will be displayed.
  926.  
  927.  
  928. 11.10 - MakeKey
  929.  
  930. Function MakeKey(Name1,Name2,Name3 : String;
  931.                  Level : Byte;
  932.                  ExpYear : Word;
  933.                  ExpMonth,ExpDay : Byte) : String;
  934.  
  935. The function MakeKey will return a string containing the 12 digit 
  936. registration key for Names and Level (using the encode functions defined 
  937. with SetEncode) specified, with an encoded expiration date of ExpYear, 
  938. ExpMonth and ExpDay. If you do not wish to use registration levels, simply 
  939. pass a 0 as the Level parameter.  If you do not wish to use expiration 
  940. dates, simply pass 0 as the ExpYear, ExpMonth and ExpDay parameters.  ExpDay 
  941. will only be used if UseExpDays is True.  Unlike the higher-level CreateKey 
  942. procedure, this function does NOT use or change the values of the Rkp 
  943. record.
  944.  
  945. Example :
  946.  
  947. Write('Enter name : ');
  948. ReadLn(n);
  949. Write('Enter company : ');
  950. ReadLn(c);
  951. Write('Enter phone number (XXX) XXX-XXXX : ');
  952. ReadLn(p);
  953. k := MakeKey(n,c,p,0,0,0,0);    { registration levels and expiration
  954.                                   dates are not being used }
  955. WriteLn;
  956. WriteLn('Registration key is ',k);
  957.  
  958. This will prompt for a name, company name and phone number.  MakeKey is then 
  959. passed the name, company name and phone number, a 0 for the registration 
  960. level and 0 for expiration year, month and day. It will return the key in 
  961. the variable k, which is then displayed.
  962.  
  963. It is usually preferable to use the higher-level CreateKey procedure, 
  964. instead of MakeKey.  MakeKey is included to allow for situations where you 
  965. may need to make a key and don't want to affect the values contained in the 
  966. Rkp record.
  967.  
  968.  
  969. 11.11 - ValidKey
  970.  
  971. Function ValidKey(Name1,Name2,Name3 : String;
  972.                   Level : Byte;
  973.                   Key : String) : Boolean;
  974.  
  975. ValidKey will return TRUE if the Key is valid for Name1, Name2, Name3 and 
  976. Level (using the encode functions defined with SetEncode).  If you do not 
  977. wish to use registration levels (and levels weren't used when the key was 
  978. generated), simply pass 0 as the Level parameter.  If ValidKey returns 
  979. False, the key is not valid. Unlike the higher-level procedure VerifyKey, 
  980. this function does NOT use or change the values of the Rkp record.
  981.  
  982. Example :
  983.  
  984. Write('Enter your name : ');
  985. ReadLn(n);
  986. Write('Enter your BBS name : ');
  987. ReadLn(b);
  988. Write('Enter your FidoNet address : ');
  989. ReadLn(f);
  990. Write('Enter your registration key : ');
  991. ReadLn(k);
  992. If Not ValidKey(n,b,f,0,k) then Begin  { registration levels not used }
  993.   WriteLn('Invalid key!');
  994.   Halt(1);
  995. End;
  996.  
  997. This programme will prompt the user to enter a name, BBS name, FidoNet 
  998. address and a registration key.   If the registration key is not valid, the 
  999. programme will display 'Invalid key!' and Halt with an errorlevel of 1.
  1000.  
  1001. It is usually preferable to use the higher-level VerifyKey procedure, 
  1002. instead of ValidKey.  ValidKey is included to allow for situations where you 
  1003. may need to validate a key and don't want to affect the values contained in 
  1004. the Rkp record.
  1005.  
  1006.  
  1007. 11.12 - SetRegInfo
  1008.  
  1009. Procedure SetRegInfo(t,s1,s2,s3,m : String;
  1010.                      l : Byte;
  1011.                      ey : Word;
  1012.                      em,ed : Byte;
  1013.                      k : String);
  1014.  
  1015. SetRegInfo makes the following assignments :
  1016.  
  1017. Rkp.ID       := t         Rkp.Level    := l 
  1018. Rkp.Name1    := s1        Rkp.ExpYear  := ey
  1019. Rkp.Name2    := s2        Rkp.ExpMonth := em
  1020. Rkp.Name3    := s3        Rkp.ExpDay   := ed
  1021. Rkp.Message  := m         Rkp.Key      := k 
  1022.  
  1023. Since the values in the Rkp record may be accessed directly, you will not 
  1024. normally need SetRegInfo.  However, if you are using MakeKey and/or ValidKey 
  1025. with temporary values, you might want to use SetRegInfo as a "short-cut" 
  1026. method of assigning those values to the Rkp record.
  1027.  
  1028. Example :
  1029.  
  1030. Write('Enter your customer ID : ');
  1031. ReadLn(i);
  1032. Write('Enter your name : ');
  1033. ReadLn(n);
  1034. Write('Enter your address (line 1) : ');
  1035. ReadLn(a1);
  1036. Write('Enter your address (line 2) : ');
  1037. ReadLn(a2);
  1038. Write('Enter your phone number : ');
  1039. ReadLn(p);
  1040. Write('Enter your registration key number : ');
  1041. ReadLn(k);
  1042. WriteLn;
  1043. If Not ValidKey(n,a1,a2,0,k) then      { registration levels not used }
  1044.   WriteLn('Registration key number invalid!')
  1045. Else
  1046.   SetRegInfo(i,n,a1,a2,p,0,0,0,0,k);
  1047.  
  1048. In the above example, the existing registration information (in the Rkp 
  1049. record) will not be changed if the registration key is invalid.  Note also 
  1050. that this example uses Rkp.ID (set to the value of the variable i) to store 
  1051. a customer number, and Rkp.Message (set to the value of the variable p) to 
  1052. store the user's phone number.  These values are not used in the encryption 
  1053. of keys and, therefore, may be used to store any information that you want.
  1054.  
  1055.  
  1056. 11.13 - CreateKey
  1057.  
  1058. Procedure CreateKey;
  1059.  
  1060. The procedure CreateKey will use the encode functions defined with SetEncode 
  1061. to generate a key encrypted from Rkp.Name1, Rkp.Name2, Rkp.Name3, Rkp.Level, 
  1062. Rkp.ExpYear, Rkp.ExpMonth (and Rkp.ExpDay, if UseExpDays is True) with an 
  1063. embedded expiration date, returning the resulting key in Rkp.Key.  If you 
  1064. don't wish to use registration levels, simply set Rkp.Level to 0 before 
  1065. calling CreateKey.  If you don't wish to use expiration dates, simply set 
  1066. Rkp.ExpYear, Rkp.ExpMonth and Rkp.ExpDay to 0 before calling CreateKey.
  1067.  
  1068. CreateKey sets the following result code, which will be returned by 
  1069. subsequent calls to RkpError :
  1070.  
  1071. BadTPU           - RKPLUS.TPU is corrupt or has been tampered with
  1072. InvalidParameter - Rkp.ExpYear, Rkp.ExpMonth or RkpDay is invalid
  1073.  
  1074. Example :
  1075.  
  1076. Write('Enter name : ');
  1077. ReadLn(Rkp.Name1);
  1078. Write('Enter company : ');
  1079. ReadLn(Rkp.Name2);
  1080. Write('Enter phone number (XXX) XXX-XXXX : ');
  1081. ReadLn(Rkp.Name3);
  1082. Rkp.Level := 0;    { registration levels are not being used }
  1083. Rkp.ExpYear := 0;  { expiration dates are not being used }
  1084. Rkp.ExpMonth := 0;
  1085. Rkp.ExpDay := 0;
  1086. CreateKey;
  1087. WriteLn;
  1088. If RkpOK then
  1089.   WriteLn('Registration key is ',Rkp.Key);
  1090.  
  1091. This will display a warning message and then prompt for a name, company 
  1092. name, and phone number.  CreateKey is called and the key is returned in 
  1093. Rkp.Key, which is then displayed, if no error has occurred.
  1094.  
  1095. Note:  It is possible to use CreateKey to create keys and then to store the 
  1096. contents of the Rkp record into your own configuration file (instead of 
  1097. using SaveRegInfo) and then read the information into your programme and use 
  1098. VerifyKey to verify that the key is valid (rather than using GetRegInfo). 
  1099. This way you can keep registration information in your own configuration 
  1100. file with other programme information, rather than in its own key file.  If 
  1101. using this method, its important that you save Rkp.Name1 (as well as 
  1102. Rkp.Name2, Rkp.Name3 and/or Rkp.Level, if used), so that keys will be built 
  1103. correctly. It is not necessary to save Rkp.ExpYear, Rkp.ExpMonth or 
  1104. Rkp.ExpDay, since the expiration date is binary-encoded in the key number 
  1105. and extracted by any call to VerifyKey.
  1106.  
  1107.  
  1108. 11.14 - VerifyKey
  1109.  
  1110. Procedure VerifyKey;
  1111.  
  1112. The procedure VerifyKey will use the encode functions defined with SetEncode 
  1113. to generate a key encrypted from Rkp.Name1, Rkp.Name2, Rkp.Name3 and 
  1114. Rkp.Level; and compare the resulting key to Rkp.Key, setting Rkp.Registered 
  1115. to True if the key is valid and not expired. Rkp.ExpYear, Rkp.ExpMonth (and 
  1116. Rkp.ExpDay, if UseExpDays is True) will be set to the expiration date 
  1117. encoded in the key.  If you don't wish to use registration levels, simply 
  1118. set Rkp.Level to 0 before calling VerifyKey.
  1119.  
  1120. VerifyKey sets the following result codes, which will be returned by 
  1121. subsequent calls to RkpError :
  1122.  
  1123. InvalidKey - Key is not valid
  1124. ExpiredKey - Key has expired
  1125. BadTPU     - RKPLUS.TPU is corrupt or has been tampered with
  1126.  
  1127. Example :
  1128.  
  1129. Write('Enter your name : ');
  1130. ReadLn(Rkp.Name1);
  1131. Write('Enter your BBS name : ');
  1132. ReadLn(Rkp.Name2);
  1133. Write('Enter your FidoNet address : ');
  1134. ReadLn(Rkp.Name3);
  1135. Write('Enter your registration key : ');
  1136. ReadLn(Rkp.Key);
  1137. Rkp.Level := 0;    { registration levels are not used }
  1138. VerifyKey;
  1139. If Not RkpOK then Begin
  1140.   Case RkpError of
  1141.     ExpiredKey : WriteLn('This key has expired!');
  1142.     InvalidKey : WriteLn('This key is invalid!');
  1143.     Else         WriteLn('Error ',RkpError);
  1144.   End;
  1145.   Halt(1);
  1146. End;
  1147.  
  1148. This programme will prompt the user to enter a name, BBS name, FidoNet 
  1149. address, and a registration key.   If the registration key has expired, 
  1150. "This key has expired!" will be displayed.  If the registration key is 
  1151. invalid, "This key is invalid!" will be displayed.  Otherwise, if an error 
  1152. has occurred, an error message will be displayed.  In any case where the key 
  1153. is not validated, the programme will halt with an errorlevel of 1.
  1154.  
  1155.  
  1156. 11.15 - GetRegInfo
  1157.  
  1158. Procedure GetRegInfo;
  1159.  
  1160. GetRegInfo will read the key file (if it exists) and set the value of the 
  1161. following variables :
  1162.  
  1163. Rkp.Name1    - set to primary registration name
  1164. Rkp.Name2    - set to secondary registration name
  1165. Rkp.Name3    - set to third registration name
  1166. Rkp.Level    - set to registration level (0 if not used)
  1167. Rkp.ExpYear  - set to expiration year (0 if not used)
  1168. Rkp.ExpMonth - set to expiration month (0 if not used)
  1169. Rkp.ExpDay   - set to expiration day (0 if not used or UseExpDays is False)
  1170. Rkp.Key      - set to 12 digit alphanumeric registration key
  1171.  
  1172. GetRegInfo would generally be called near the beginning of a programme 
  1173. (after SetEncode has been called to define the encode functions and 
  1174. SetKeyFile has been called to define the key file).
  1175.  
  1176. GetRegInfo sets the following result codes, which will be returned by
  1177. subsequent calls to RkpError :
  1178.  
  1179. ExpiredKey  - Registration key has expired
  1180. InvalidKey  - programme is registered with an invalid key
  1181. InvalidFile - File is not a RkPlus(tm) registration key file
  1182. BadTPU      - RKPLUS.TPU is corrupt or has been tampered with
  1183.  
  1184. Example :
  1185.  
  1186. GetRegInfo;
  1187. If Rkp.Registered then
  1188.   WriteLn('Registered to ',Rkp.Name1);
  1189.  
  1190. GetRegInfo will read the key file (specified in an earlier call to 
  1191. SetKeyFile). If the programme is registered, Rkp.Registered will be True and 
  1192. the programme will display the name of the person that the programme is 
  1193. registered to.
  1194.  
  1195.  
  1196. 11.16 - SaveRegInfo
  1197.  
  1198. Procedure SaveRegInfo;
  1199.  
  1200. The procedure SaveRegInfo will use the encode functions defined with 
  1201. SetEncode to generate a key encrypted from Rkp.Name1, Rkp.Name2, Rkp.Name3, 
  1202. Rkp.Level, Rkp.ExpYear, Rkp.ExpMonth (and Rkp.ExpDay, if UseExpDays is 
  1203. True). It will them compare the resulting key with Rkp.Key and write the 
  1204. contents of the Rkp record to the keyfile.  If you don't wish to use 
  1205. registration levels, simply set Rkp.Level to 0 before calling SaveRegInfo. 
  1206. If you don't wish to use expiration dates, simply set Rkp.ExpYear, 
  1207. Rkp.ExpMonth, and Rkp.ExpDay to 0 before calling SaveRegInfo.
  1208.  
  1209. SaveRegInfo sets the following result codes, which will be returned by 
  1210. subsequent calls to RkpError :
  1211.  
  1212. InvalidKey - Key is not valid
  1213. BadTPU     - RKPLUS.TPU is corrupt or has been tampered with
  1214.  
  1215. Example :
  1216.  
  1217. Write('Enter your name : ');
  1218. ReadLn(Rkp.Name1);
  1219. Write('Enter your company name : ');
  1220. ReadLn(Rkp.Name2);
  1221. Write('Enter your registration key : ');
  1222. ReadLn(Rkp.Key);
  1223. Rkp.Level := 0;    { registration levels not used }
  1224. Rkp.ExpYear := 0;  { expiration dates not used }
  1225. Rkp.ExpMonth := 0;
  1226. Rkp.ExpDay := 0;
  1227. SaveRegInfo;
  1228. If Not RkpOK then
  1229.   WriteLn('Invalid Key or File Error.  Programme not installed.');
  1230.  
  1231. This programme will prompt the user for a name, company name, and a 
  1232. registration key.  SaveRegInfo will then be called. If Rkp.Registered is not 
  1233. True, then an error occurred and no key file was written (the programme 
  1234. displays 'Invalid Key or File Error.  Programme not installed.'). Otherwise, 
  1235. the key file was written.
  1236.  
  1237.  
  1238. 11.17 - BrandRegInfo
  1239.  
  1240. Procedure BrandRegInfo;
  1241.  
  1242. The procedure BrandRegInfo will use the encode functions defined with 
  1243. SetEncode to generate a key encrypted from Rkp.Name1, Rkp.Name2, Rkp.Name3, 
  1244. Rkp.Level, Rkp.ExpYear, Rkp.ExpMonth (and Rkp.ExpDay, if UseExpDays is 
  1245. True). It will them compare the resulting key with Rkp.Key and brand the 
  1246. contents of the Rkp record to the EXE file.  If you don't wish to use 
  1247. registration levels, simply set Rkp.Level to 0 before calling BrandRegInfo. 
  1248. If you don't wish to use expiration dates, simply set Rkp.ExpYear, 
  1249. Rkp.ExpMonth, and Rkp.ExpDay to 0 before calling BrandRegInfo.
  1250.  
  1251. BrandRegInfo sets the following result codes, which will be returned by 
  1252. subsequent calls to RkpError :
  1253.  
  1254. InvalidKey  - Key is not valid
  1255. InvalidFile - EXE file is NOT an RkPlus(tm) 3.x file
  1256. BadTPU      - RKPLUS.TPU is corrupt or has been tampered with
  1257.  
  1258. Example :
  1259.  
  1260. Write('Enter your name : ');
  1261. ReadLn(Rkp.Name1);
  1262. Write('Enter your company name : ');
  1263. ReadLn(Rkp.Name2);
  1264. Write('Enter your registration key : ');
  1265. ReadLn(Rkp.Key);
  1266. Rkp.Level := 0;    { registration levels not used }
  1267. Rkp.ExpYear := 0;  { expiration dates not used }
  1268. Rkp.ExpMonth := 0;
  1269. Rkp.ExpDay := 0;
  1270. BrandRegInfo;
  1271. If Not Rkp.Registered then
  1272.   WriteLn('Invalid Key or File Error.  Programme not branded.');
  1273.  
  1274. This programme will prompt the user for a name, company name, and a 
  1275. registration key.  BrandRegInfo will then be called. If Rkp.Registered is 
  1276. not True, then an error occurred and the EXE file was not modified (the 
  1277. programme displays 'Invalid Key or File Error.  Programme not branded.'). 
  1278. Otherwise, the EXE file was modified to include the registration 
  1279. information.
  1280.  
  1281. Note:  BrandRegInfo has NOT been tested with any EXE-compression programmes. 
  1282. Because of the way that RkPlus(tm) searches for it's ID stamp, it will most 
  1283. likely NOT work on "compressed" files.  Calls to BrandRegInfo (when the EXE 
  1284. file set with SetKeyFile has been "compressed") will probably set the result 
  1285. code of InvalidFile.
  1286.  
  1287.  
  1288. 11.18 - SetFileEnc
  1289.  
  1290. Procedure SetFileEnc(ef : FileFuncType);
  1291.  
  1292. This procedure is used to specify the File Encoding Function that will be 
  1293. used by RkPlus(tm) to "scramble" key files (see KeyFileCode).  It is 
  1294. automatically set by Rkp2Enc and Rkp3Enc.  You will only need to use 
  1295. SetFileEnc if you are using user-written encoding functions.
  1296.  
  1297.  
  1298. 12.0 - Additional Information On RkPlus(tm)
  1299.  
  1300. For more information on using RkPlus(tm), see the sample Turbo Pascal (tm) 
  1301. programmes that are distributed with the archive, or contact me at any of 
  1302. the locations listed below.
  1303.  
  1304.  
  1305. 13.0 - RkPlus(tm) Source Code Availability
  1306.  
  1307. Starting with version 3.0, the source code to RkPlus(tm) (as well as the 
  1308. smaller rKey unit) is available to licenced users.  Since SetEncode was 
  1309. added, allowing programmers to write their own encoding functions, the 
  1310. security of programmes written with RkPlus(tm) are no longer compromised by 
  1311. releasing the source code.  See REGISTER.USA or REGISTER.EUR for more 
  1312. information.
  1313.  
  1314.  
  1315. 14.0 - What's Next For RkPlus(tm)?
  1316.  
  1317. I am currently working on WriteRegTag and ReadRegTag, which will allow 
  1318. registration information to be written to and read from the end of existing 
  1319. files (text files, compressed EXE files, etc).
  1320.  
  1321. I am also working to streamline the user-written encoding process, to make 
  1322. it easier for programmers to write their own encode units.
  1323.  
  1324. I still hope to eventually release QuickBASIC(tm) and C versions of 
  1325. RkPlus(tm), but limitations of BASIC and my limited knowledge of C have 
  1326. caused it to be a more daunting task than I had anticipated.
  1327.  
  1328. If you have any suggestions for features that you'd like to see in future 
  1329. versions of RkPlus(tm), feel free to contact me via any of the methods 
  1330. below. I welcome questions, comments and suggestions of any kind.
  1331.  
  1332.  
  1333. 15.0 - ShareWare Notice And Registration
  1334.  
  1335. RkPlus(tm) is Shareware.  You may copy and distribute the RKPLUS33 archive 
  1336. freely.  All I ask is that you include all of the original files, 
  1337. unmodified, and that you do not charge for the distribution of RkPlus(tm) 
  1338. itself.  If you use RkPlus(tm) to develop software, you are required to 
  1339. register BEFORE releasing it (see REGISTER.USA or REGISTER.EUR for 
  1340. registration information).
  1341.  
  1342. There are no royalties for the distribution of programmes that are written 
  1343. with RkPlus(tm).  A single registration fee entitles you to write and 
  1344. distribute any number of programmes using RkPlus(tm).
  1345.  
  1346. Questions, comments, and suggestions are welcome.
  1347.  
  1348. Send US Mail to:
  1349.   Serious Cybernetics
  1350.   6804 Belton Place
  1351.   Lula, GA  30554-2622 USA
  1352.  
  1353. You may also contact me at either of the BBS's listed below, or via the 
  1354. Serious Cybernetics Echo on CyberNet.
  1355.  
  1356.  
  1357. 16.0 - RkPlus(tm) Support
  1358.  
  1359. The latest version of RkPlus(tm) can always be downloaded from either of
  1360. our support BBS's below.
  1361.  
  1362. In the United States and Canada :
  1363.  
  1364.                P h o e n i x   S t a r F i g h t e r   B B S
  1365.       The Home of "Serious Cybernetics"  -  FidoNet/CyberNet 1:3616/20
  1366.     (404) 869-3410  -  Lula, Georgia, USA  -  24 Hour Service (excl NMH)
  1367.   Supporting 3/12/24/48/96/144/HST/v32/v32b/v42/v42b via USR HST/DS Modem
  1368.                    Sysops:  Danny Sosebee and Scott Davis
  1369.                    All Users Welcome!   Immediate Access!
  1370.  
  1371.   We have the following "magic" filenames set up for FidoNet file requests :
  1372.  
  1373.     "FILES"  will request the current master file listing (updated nightly)
  1374.     "CYBER"  will request the current CyberNet info pack and file list
  1375.     "RKPLUS" will request the latest version of RkPlus(tm)
  1376.     "RKHELP" will request the latest version of RkPlus(tm) Help
  1377.     "RKP"    will request the latest version of ALL RkPlus(tm) files
  1378.  
  1379. In the United Kingdom and Europe :
  1380.  
  1381.                           F r o n t i e r s   BBS
  1382.     European Home of "Serious Cybernetics"  -  FidoNet/CyberNet 2:440/63
  1383.             Tel +44-(0)737-778607 - 24 hours Per Day (excl NMH)
  1384.                             Sysop:  Dave Parker
  1385.                              All Users Welcome!
  1386.  
  1387.  
  1388. 17.0 - Credits
  1389.  
  1390. I'd like to thank Danny Sosebee (Sysop of Phoenix StarFighter BBS) for 
  1391. allowing me to distribute my software through his BBS, as well as for 
  1392. helping me rewrite and "clean-up" the documentation and help files.  Also, 
  1393. I'd like to thank Ed Ivey (Sysop of Ed's Place BBS - 404-532-1978 - FidoNet 
  1394. Node 1:3616/1) for his continued support and assistance with my little 
  1395. software "projects".  I would also like to thank Dave Parker (Sysop of 
  1396. Frontiers BBS) for volunteering to become our European distribution, support 
  1397. and registration site.
  1398.  
  1399. In addition, I'd like to thank the following users of RkPlus(tm) who have 
  1400. made valuable suggestions :
  1401.  
  1402. Nick Herceg - Made MANY excellent suggestions (too many to list here), which 
  1403. led directly to the rewriting of rKey as RkPlus(tm). [2.0]
  1404.  
  1405. Mike Janke - The FIRST user to register RkPlus(tm) (thanks, Mike!).  He also 
  1406. suggested that the key file extension (previously .REG) be definable.  [2.3]
  1407.  
  1408. Luke Kolin - Suggested a definable key file size (padded with random 
  1409. characters) to confuse potential hackers. [2.3]
  1410.  
  1411. Mats Engstrom - Found and reported bugs in the version 2.x encoding 
  1412. functions and in the key validation routine when the expiration month was 
  1413. set to 12 (December).  [2.4]
  1414.  
  1415. Tom Thayer - Reported the naming conflict between the registration record 
  1416. and some programmes/units that use Reg to contain registers.  Also, made me 
  1417. aware of how vulnerable RKPLUS.TPU was to "tampering".  [2.4]
  1418.  
  1419. Aaron Blanton - Made me aware of the possibility of programmers/hackers 
  1420. examining the EXE file to determine the constants used in the version 2.x 
  1421. encoding functions.  [2.4]  This led directly to the encryption method used 
  1422. in Rkp3Enc and programmer-definable encode functions. [3.0]
  1423.  
  1424. Joe Dabrowski - Suggested that I allow the key file to be "scrambled" 
  1425. (KeyFileCode).  [3.0]
  1426.  
  1427. Rand Nowell and Markus Bartsch - Found and reported a bug in the version 3.x 
  1428. expiration date algorythm when UseExpDays was set to True.  [3.2]  Rand also 
  1429. helped me isolate and resolve a related bug in VerifyKey.  [3.3]
  1430.  
  1431. Finally, I'd like to thank all of the REGISTERED users of RkPlus(tm) whose 
  1432. support keeps the ShareWare concept alive.
  1433.  
  1434.  
  1435. 18.0 - Turbo Pascal (tm) Units from Serious Cybernetics
  1436.  
  1437. The following Turbo Pascal (tm) units are available from Serious
  1438. Cybernetics :
  1439.  
  1440.   CmdParse 1.02 - TP55/60/TPW10/15 Command Line Parsing Unit
  1441.   rKey 1.7      - TP50/55/60 Simple Registration Key Unit
  1442.   RkPlus 3.3    - TP50/55/60/70/TPW10/15/BP70/SBP+ Enhanced Reg Key Unit
  1443.   StrLib 1.4    - TP String Library Unit (with source)
  1444.  
  1445.  
  1446. 19.0 - Other Recommended Turbo Pascal (tm) Units
  1447.  
  1448. I use units from Object Professional (tm) from TurboPower Software in almost 
  1449. every programme that I write, and strongly recommend it (as well as any 
  1450. other units from Turbo Power) to any Turbo Pascal (tm) programmer.  
  1451. ObjectPro has been, for me, the single most useful collection of general 
  1452. purpose units that I have ever run across.
  1453.  
  1454.  
  1455. 20.0 - Copyright Notices
  1456.  
  1457. RkPlus (c) 1991-93 Serious Cybernetics
  1458. Rkp2Enc (c) 1990-93 Serious Cybernetics
  1459. Rkp3Enc (c) 1993 Serious Cybernetics
  1460. CmdParse (c) 1992-93 Serious Cybernetics
  1461. rKey, StrLib (c) 1990-92 Serious Cybernetics
  1462. Turbo Pascal (c) 1983-89 Borland International
  1463. Borland Pascal (c) 1983-93 Borland International
  1464. Stony Brook Pascal+ (c) 1987-93 Stony Brook Software
  1465. Object Professional (c) 1989 TurboPower Software
  1466. Microsoft Windows (c) 1985-92 Microsoft Corporation
  1467. QuickBASIC (c) 1982-88 Microsoft Corporation
  1468.