~ubuntu-branches/ubuntu/precise/arj/precise-security

« back to all changes in this revision

Viewing changes to make_key.c

  • Committer: Bazaar Package Importer
  • Author(s): Guillem Jover
  • Date: 2004-06-27 08:07:09 UTC
  • Revision ID: james.westby@ubuntu.com-20040627080709-1gkxm72ex66gkwe4
Tags: upstream-3.10.21
ImportĀ upstreamĀ versionĀ 3.10.21

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: make_key.c,v 1.3 2003/10/20 20:49:15 andrew_belov Exp $
 
3
 * ---------------------------------------------------------------------------
 
4
 * This is a key generation utility.
 
5
 *
 
6
 */
 
7
 
 
8
#include "arj.h"
 
9
 
 
10
#include <stdlib.h>
 
11
 
 
12
DEBUGHDR(__FILE__)                      /* Debug information block */
 
13
 
 
14
/* Main routine */
 
15
 
 
16
int main(int argc, char **argv)
 
17
{
 
18
 FILE *stream;
 
19
 int i, rc;
 
20
 unsigned long validation[8];
 
21
 
 
22
 printf("MAKE_KEY v 1.13  [16/12/2000]  Not a part of any binary package!\n\n");
 
23
 if(argc<5)
 
24
 {
 
25
  printf("Usage: MAKE_KEY \"<username>\" <license code> <product ID> <filename>\n"
 
26
         "Where: <username> is the quoted \"<name> [<license>] [<ARJ key>|<SDN key>]\n"
 
27
         "                     <name> is a free-form string\n"
 
28
         "                  <license> is \"(EXT LIC)\" if extended license\n"
 
29
         "                  <ARJ key> is \"R#nnnn\", zero-padded\n"
 
30
         "                  <SDN key> is \"SDN#0xnnnn\", where x is:\n"
 
31
         "                               1 is for SDN-originated packages\n"
 
32
         "                               2 is for SDN-distributed packages\n"
 
33
         "   <license code> is the license code (e.g., ARJR#1)\n"
 
34
         "                               ARJR#1 is a private license\n"
 
35
         "                               ARJR#2 is a public license\n"
 
36
         "     <product ID> is a product version number: <series><version>\n"
 
37
         "                   <series> is product series (\"A\" for ARJ)\n"
 
38
         "                  <version> is product version (\"3\" for v 3.x)\n"
 
39
         "       <filename> is the name of file which accepts the registration data\n"
 
40
         "\n"
 
41
         "Example: MAKE_KEY \"John Doe (EXT LIC) R#0843\" ARJR#2 A2 arj.key\n");
 
42
  exit(1);
 
43
 }
 
44
 printf("Initializing...\n");
 
45
 build_crc32_table();
 
46
 printf("Creating key signature...\n");
 
47
 create_reg_key(argv[2], argv[3], argv[1], (char *)validation);
 
48
 rc=verify_reg_name(argv[2], argv[3], argv[1], (char *)validation);
 
49
 printf("Verifying key... RC = %d\n", rc);
 
50
 if(rc==0)
 
51
 {
 
52
  if((stream=fopen(argv[4], "w"))!=NULL)
 
53
  {
 
54
   for(i=0; i<8; i++)
 
55
    fprintf(stream, "%10lu ", validation[i]);
 
56
   fprintf(stream, "%s %s %s", argv[2], argv[3], argv[1]);
 
57
   fclose(stream);
 
58
  }
 
59
  printf("ARJ-SECURITY calculation completed.\n");
 
60
  return(0);
 
61
 }
 
62
 else
 
63
 {
 
64
  printf("Key creation error!\n");
 
65
  return(1);
 
66
 }
 
67
}